at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:515)
<p>Im using a Road Provider class for directions</p>

<p>Here's the code :</p>

<pre><code>public class RoadProvider {

    public static Road getRoute(InputStream is) {
        KMLHandler handler = new KMLHandler();
        try {
            SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
            parser.parse(is, handler);
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return handler.mRoad;
    }

    public static String getUrl(double fromLat, double fromLon, double toLat,
            double toLon) {// connect to map web service
        StringBuffer urlString = new StringBuffer();
        urlString.append("http://maps.google.com/maps?f=d&amp;hl=en");
        urlString.append("&amp;saddr=");// from
        urlString.append(Double.toString(fromLat));
        urlString.append(",");
        urlString.append(Double.toString(fromLon));
        urlString.append("&amp;daddr=");// to
        urlString.append(Double.toString(toLat));
        urlString.append(",");
        urlString.append(Double.toString(toLon));
        urlString.append("&amp;ie=UTF8&amp;0&amp;om=0&amp;output=kml");
        return urlString.toString();
    }
}
</code></pre>

<p>And the DefaultHandler</p>

<pre><code>class KMLHandler extends DefaultHandler {

    Road mRoad;
    boolean isPlacemark;
    boolean isRoute;
    boolean isItemIcon;
    private Stack mCurrentElement = new Stack();
    private String mString;

    public KMLHandler() {
            mRoad = new Road();
    }

    public void startElement(String uri, String localName, String name,
                    Attributes attributes) throws SAXException {
            mCurrentElement.push(localName);
            if (localName.equalsIgnoreCase("Placemark")) {
                    isPlacemark = true;
                    mRoad.mPoints = addPoint(mRoad.mPoints);
            } else if (localName.equalsIgnoreCase("ItemIcon")) {
                    if (isPlacemark)
                            isItemIcon = true;
            }
            mString = new String();
    }

    public void characters(char[] ch, int start, int length)
                    throws SAXException {
            String chars = new String(ch, start, length).trim();
            mString = mString.concat(chars);
    }

    public void endElement(String uri, String localName, String name)
                    throws SAXException {
            if (mString.length() &gt; 0) {
                    if (localName.equalsIgnoreCase("name")) {
                            if (isPlacemark) {
                                    isRoute = mString.equalsIgnoreCase("Route");
                                    if (!isRoute) {
                                            mRoad.mPoints[mRoad.mPoints.length - 1].mName = mString;
                                    }
                            } else {
                                    mRoad.mName = mString;
                            }
                    } else if (localName.equalsIgnoreCase("color") &amp;&amp; !isPlacemark) {
                            mRoad.mColor = Integer.parseInt(mString, 16);
                    } else if (localName.equalsIgnoreCase("width") &amp;&amp; !isPlacemark) {
                            mRoad.mWidth = Integer.parseInt(mString);
                    } else if (localName.equalsIgnoreCase("description")) {
                            if (isPlacemark) {
                                    String description = cleanup(mString);
                                    if (!isRoute)
                                            mRoad.mPoints[mRoad.mPoints.length - 1].mDescription = description;
                                    else
                                            mRoad.mDescription = description;
                            }
                    } else if (localName.equalsIgnoreCase("href")) {
                            if (isItemIcon) {
                                    mRoad.mPoints[mRoad.mPoints.length - 1].mIconUrl = mString;
                            }
                    } else if (localName.equalsIgnoreCase("coordinates")) {
                            if (isPlacemark) {
                                    if (!isRoute) {
                                            String[] xyParsed = split(mString, ",");
                                            double lon = Double.parseDouble(xyParsed[0]);
                                            double lat = Double.parseDouble(xyParsed[1]);
                                            mRoad.mPoints[mRoad.mPoints.length - 1].mLatitude = lat;
                                            mRoad.mPoints[mRoad.mPoints.length - 1].mLongitude = lon;
                                    } else {
                                            String[] coodrinatesParsed = split(mString, " ");
                                            mRoad.mRoute = new double[coodrinatesParsed.length][2];
                                            for (int i = 0; i &lt; coodrinatesParsed.length; i++) {
                                                    String[] xyParsed = split(coodrinatesParsed[i], ",");
                                                    for (int j = 0; j &lt; 2 &amp;&amp; j &lt; xyParsed.length; j++)
                                                            mRoad.mRoute[i][j] = Double
                                                                            .parseDouble(xyParsed[j]);
                                            }
                                    }
                            }
                    }
            }
            mCurrentElement.pop();
            if (localName.equalsIgnoreCase("Placemark")) {
                    isPlacemark = false;
                    if (isRoute)
                            isRoute = false;
            } else if (localName.equalsIgnoreCase("ItemIcon")) {
                    if (isItemIcon)
                            isItemIcon = false;
            }
    }

    private String cleanup(String value) {
            String remove = "&lt;br/&gt;";
            int index = value.indexOf(remove);
            if (index != -1)
                    value = value.substring(0, index);
            remove = "&amp;#160;";
            index = value.indexOf(remove);
            int len = remove.length();
            while (index != -1) {
                    value = value.substring(0, index).concat(
                                    value.substring(index + len, value.length()));
                    index = value.indexOf(remove);
            }
            return value;
    }

    public Point[] addPoint(Point[] points) {
            Point[] result = new Point[points.length + 1];
            for (int i = 0; i &lt; points.length; i++)
                    result[i] = points[i];
            result[points.length] = new Point();
            return result;
    }

    private static String[] split(String strString, String strDelimiter) {
            String[] strArray;
            int iOccurrences = 0;
            int iIndexOfInnerString = 0;
            int iIndexOfDelimiter = 0;
            int iCounter = 0;
            if (strString == null) {
                    throw new IllegalArgumentException("Input string cannot be null.");
            }
            if (strDelimiter.length() &lt;= 0 || strDelimiter == null) {
                    throw new IllegalArgumentException(
                                    "Delimeter cannot be null or empty.");
            }
            if (strString.startsWith(strDelimiter)) {
                    strString = strString.substring(strDelimiter.length());
            }
            if (!strString.endsWith(strDelimiter)) {
                    strString += strDelimiter;
            }
            while ((iIndexOfDelimiter = strString.indexOf(strDelimiter,
                            iIndexOfInnerString)) != -1) {
                    iOccurrences += 1;
                    iIndexOfInnerString = iIndexOfDelimiter + strDelimiter.length();
            }
            strArray = new String[iOccurrences];
            iIndexOfInnerString = 0;
            iIndexOfDelimiter = 0;
            while ((iIndexOfDelimiter = strString.indexOf(strDelimiter,
                            iIndexOfInnerString)) != -1) {
                    strArray[iCounter] = strString.substring(iIndexOfInnerString,
                                    iIndexOfDelimiter);
                    iIndexOfInnerString = iIndexOfDelimiter + strDelimiter.length();
                    iCounter += 1;
            }

            return strArray;
    }
</code></pre>

<p>Here's the log cat:</p>

<pre><code>11-22 16:46:55.817: W/System.err(25038): org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 798: not well-formed (invalid token)
11-22 16:46:55.817: W/System.err(25038):    at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:515)
11-22 16:46:55.817: W/System.err(25038):    at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
11-22 16:46:55.827: W/System.err(25038):    at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
11-22 16:46:55.827: W/System.err(25038):    at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
11-22 16:46:55.827: W/System.err(25038):    at com.example.testdirection.RoadProvider.getRoute(RoadProvider.java:35)
11-22 16:46:55.827: W/System.err(25038):    at com.example.testdirection.MainActivity$2.run(MainActivity.java:143)
</code></pre>

<p>Wts wrong here.</p>
