我有以下xml文件
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Placemark>
<name>Simple placemark</name>
<description>Attached to the ground. Intelligently places itself at the
height of the underlying terrain.</description>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark>
</kml>
</resources>
如何读取标签之间的数字而不是属性???
<coordinates> -122.0822035425683,37.42228990140251,0</coordinates>
我在处理程序中有这个
XMLDataColleted info = new XMLDataColleted();
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
// TODO Auto-generated method stub
if (localName.equals("coordinates")){
double X = /// need help here how to get the number ;
double Y = // here also ?? ;
info.setx(X) ;
info.sety(Y) ;
}
else if ( localName.equals("description")){
String s = // the discreption // need help here;
info.setDis(s) ;
}
答案 0 :(得分:0)
在SAX解析器中,我们有另一个重写方法:
@Override
public void characters(char ch[], int start, int length) {
String chars = new String(ch, start, length);
chars = chars.trim();
if(_inCoordinates) {
_data.coordinates = chars;
}
}
您可以查看此link作为示例。