Android - Help me with NodeList

I have a problem. I want to check the result of the analysis.

I have a kml document from a Google Maps request. here is my KML document

<LineString>
    <coordinates>
        106.826200,-6.297500,0.000000 
        106.826220,-6.297260,0.000000 
        106.826380,-6.297050,0.000000 
        106.826900,-6.296710,0.000000 
        106.827120,-6.296640,0.000000 
        106.827120,-6.296640,0.000000 
        106.827170,-6.296510,0.000000 
        106.827140,-6.296370,0.000000 
        106.827140,-6.296370,0.000000 
        106.826210,-6.295840,0.000000 
        106.824970,-6.295220,0.000000 
        106.823550,-6.294580,0.000000 
        106.822690,-6.293830,0.000000 
        106.822860,-6.293800,0.000000 
        106.823820,-6.294160,0.000000 
        106.825240,-6.294830,0.000000 
        106.830400,-6.297550,0.000000 
        106.831360,-6.298100,0.000000 
        106.885600,-6.293860,0.000000 
    </coordinates>
</LineString>

and this is my code:

NodeList nl = doc.getElementsByTagName("LineString");
        for(int s = 0; s < nl.getLength(); s++){
            Node rootNode = nl.item(s);
            NodeList configItems = rootNode.getChildNodes();
            for(int x = 0; x < configItems.getLength(); x++){
                Node lineStringNode = configItems.item(x);
                NodeList path = lineStringNode.getChildNodes();
                pathConent = path.item(0).getNodeValue();
            }
        }

the parser is successful and I can draw a route on a google map. but now I want to know how this works, so I want to print the coordinates of the TextView. and here is my new code:

NodeList nl = doc.getElementsByTagName("LineString");
        for(int s = 0; s < nl.getLength(); s++){
            Node rootNode = nl.item(s);
            NodeList configItems = rootNode.getChildNodes();
            for(int x = 0; x < configItems.getLength(); x++){
                Node lineStringNode = configItems.item(x);
                NodeList path = lineStringNode.getChildNodes();
                pathConent = path.item(0).getNodeValue();
            }
        }
    String[] tempContent = pathConent.split(" ");
            for (int i = 0; i < tempContent.length; i++){
                koor.setText("Latitude, Longitude:\n" + tempContent[i] + "\n");
            }

but why in my TextView I got only the first coordinates (106.826200, -6.297500,0.000000). can help me solve my problems?

Thank you and they are very sorry that my English> _ <

+3
source share
1 answer

use

    String[] tempContent = pathConent.split(" ");
    koor.setText("");
    for (int i = 0; i < tempContent.length; i++){
        koor.append("Latitude, Longitude:\n" + tempContent[i] + "\n");
    }

instead

String[] tempContent = pathConent.split(" ");
        for (int i = 0; i < tempContent.length; i++){
            koor.setText("Latitude, Longitude:\n" + tempContent[i] + "\n");
        }
+2
source

All Articles