1

i've a problem here. i wanna parsing a KML document from google maps. i'd successfuly to parsing the nodes which stores a coordinate.

but i wanna parse the node as childnodes here is the KML documents.

<Placemark>
<name>Head north on Jalan Kebagusan Raya toward Jalan Anggrek</name>
<description><![CDATA[go 850&#160;m]]></description>
<address>Jalan Kebagusan Raya</address>
...
</Placemark

to parse it i used this code,

NodeList nlPlace = doc.getElementsByTagName("Placemark");
        for(int p = 0; p < nlPlace.getLength(); p++){
            Node rootPlace = nlPlace.item(p);
            NodeList itemPlace = rootPlace.getChildNodes();
            for(int y = 0; y < itemPlace.getLength(); y++){
                Node placeStringNode = itemPlace.item(y);
                NodeList place = placeStringNode.getChildNodes();
                //valueName = nameList.item(0).getNodeValue().toString() + "+";
                pathName.add(place.item(0).getNodeValue());
            }
        }

desk.setText("");
        for (int j = 0; j < strPlace.length; j++){
            desk.append("Deskripsi:\n" + strPlace[j] + "\n");
        }

but when i tried in a real device/emulator, i got something i dont want to. this is the screenshot from my real device enter image description here

from the scrshot, i just want to grab the "Head northeast on Jalan Darmo Kali toward Jalan Darmoerjo 4" informations. just it.

can u help me to solve my problems?

thanks in advance, and sorry for my english, thanks :)

1 Answer 1

1

Something like the following should do what you want.

NodeList nlPlace = doc.getElementsByTagName("Placemark");
for(int p = 0; p < nlPlace.getLength(); p++){
    Element place = (Element)nlPlace.item(p);
    Element name = (Element)place.getElementsByTagName("name");

    //.....
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.