Itt a forrás XML:private static final class SaxHandler extends DefaultHandler {
public void startElement(String uri, String localName,
String qName, Attributes attrs, TextView textView) throws SAXException {
if (qName.equals("node")) {
// order date value as String:
String id = attrs.getValue("id");
// order number as a String:
String visible = attrs.getValue("visible");
String lat = attrs.getValue("lat");
String lon = attrs.getValue("lon");
textView.setText(id);
textView.setText(visible);
textView.setText(lat);
textView.setText(lon);
// System.out.println("Order #" + number + " date is '" +date + "'");
}
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(new SampleView(this));
TextView textView = new TextView(this);
try {
// creates and returns new instance of SAX-implementation:
SAXParserFactory factory = SAXParserFactory.newInstance();
// create SAX-parser...
SAXParser parser = factory.newSAXParser();
// .. define our handler:
SaxHandler handler = new SaxHandler();
// and parse:
parser.parse("D:\\Diplomamunka\\ujszeged.xml", handler);
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
setContentView(textView);
<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
<node id='-1' visible='true' lat='-1.377' lon='-1.3635' />
<node id='-2' visible='true' lat='-2.493' lon='-0.8684999999999999' />
<node id='-3' visible='true' lat='-2.889' lon='-0.2925' />
<node id='-4' visible='true' lat='-2.1731531008265907' lon='-1.0103675762462703' />
<node id='-5' visible='true' lat='-1.17173167547311' lon='-0.39861659247471204' />
<node id='-6' visible='true' lat='-0.6922364241169185' lon='-0.10570125802657904' />
<node id='-7' visible='true' lat='3.033' lon='-3.4425' />
<node id='-8' visible='true' lat='1.809' lon='-3.7754999999999996' />
<node id='-9' visible='true' lat='1.341' lon='-4.0275' />
<node id='-10' visible='true' lat='1.143' lon='-4.0634999999999994' />
<node id='-11' visible='true' lat='1.008' lon='-4.0095' />
<node id='-12' visible='true' lat='0.9179999999999999' lon='-3.9465' />
<node id='-13' visible='true' lat='2.3983853072967456' lon='-3.6151525266913263' />
<node id='-14' visible='true' lat='1.1499578470195202' lon='-2.6031083483750397' />
<node id='-15' visible='true' lat='-1.5140421529804802' lon='1.338891651624961' />
<node id='-16' action='modify' visible='true' lat='-2.7920421529804806' lon='3.660891651624961' />
<node id='-17' action='modify' visible='true' lat='-0.8300421529804803' lon='4.6688916516249614' />
<node id='-18' visible='true' lat='1.3479578470195202' lon='0.2993916516249608' />
<node id='-19' visible='true' lat='1.0257578470195203' lon='0.9437916516249611' />
<way id='-20' action='modify' visible='true'>
<nd ref='-7' />
<nd ref='-13' />
<nd ref='-8' />
<nd ref='-9' />
<nd ref='-10' />
<nd ref='-11' />
<nd ref='-12' />
<nd ref='-1' />
<nd ref='-4' />
<nd ref='-2' />
<nd ref='-3' />
<tag k='ref' v='43' />
<tag k='highway' v='primary' />
<tag k='name' v='Szőregi út' />
</way>
<way id='-21' action='modify' visible='true'>
<nd ref='-13' />
<nd ref='-18' />
<nd ref='-19' />
<nd ref='-17' />
<tag k='ref' v='Fő fasor' />
<tag k='highway' v='unclassified' />
<tag k='name' v='Fő fasor' />
</way>
<way id='-22' action='modify' visible='true'>
<nd ref='-4' />
<nd ref='-5' />
<nd ref='-6' />
<nd ref='-19' />
<tag k='highway' v='unclassified' />
<tag k='name' v='Thököly utca' />
</way>
<way id='-23' action='modify' visible='true'>
<nd ref='-5' />
<nd ref='-14' />
<nd ref='-8' />
<tag k='highway' v='unclassified' />
<tag k='name' v='Derkovits fasor' />
</way>
<way id='-24' action='modify' visible='true'>
<nd ref='-6' />
<nd ref='-15' />
<tag k='highway' v='unclassified' />
<tag k='name' v='Hársfa utca' />
</way>
<way id='-25' action='modify' visible='true'>
<nd ref='-15' />
<nd ref='-16' />
<tag k='highway' v='unclassified' />
<tag k='name' v='Katalin utca' />
</way>
<way id='-26' action='modify' visible='true'>
<nd ref='-16' />
<nd ref='-17' />
<tag k='highway' v='unclassified' />
<tag k='name' v='Ágnes utca' />
</way>
</osm>