ここで問題があります。パーサーの結果をテストしたい。
リクエストから Google マップへの kml ドキュメントがあります。ここに私のKMLドキュメントがあります
<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>
これは私のコードです:
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();
}
}
パーサーは正常に機能し、Google マップにルートを描画できます。しかし、今はその仕組みを知りたいので、座標を TextView に出力したいと思います。ここに私の新しいコードがあります:
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");
}
しかし、なぜ私のTextViewでは最初の座標(106.826200、-6.297500、0.000000)しか得られなかったのですか。私の問題を解決するのを手伝ってもらえますか?
ありがとう、そして私の英語について本当に申し訳ありません>_<