public void parseKml( InputStream in ) throws IOException { Reader reader = new InputStreamReader( in ); XmlParser parser = new XmlParser( reader ); ParseEvent pe = null; Attribute atr = null; pe = parser.read(); parser.skip(); parser.read( Xml.START_TAG, null, "kml" ); parser.skip(); parser.read( Xml.START_TAG, null, "Document" ); boolean trucking = true; boolean first = true; int index = 0; while( trucking ) { pe = parser.read(); if( pe.getType() == Xml.START_TAG ) { String name = pe.getName(); if( name.equals( "Placemark" ) ) { String nam = ""; String dsc = ""; String lon = ""; String lat = ""; while( ( pe.getType() != Xml.END_TAG) || ( pe.getName().equals( name ) == false ) ) { pe = parser.read(); if( pe.getType() == Xml.START_TAG && pe.getName().equals( "name" ) ) { pe = parser.read(); nam = pe.getText(); } else if(pe.getType() == Xml.START_TAG && pe.getName().equals( "description" ) ) { pe = parser.read(); dsc = pe.getText(); } else if(pe.getType() == Xml.START_TAG && pe.getName().equals( "Point" ) ) { pe = parser.read(); // cita pokial nie je koniec Pointu while( ( pe.getType() != Xml.END_TAG) || ( pe.getName().equals( "Point" ) == false ) ) { pe = parser.read(); // ak narazi na Coordinates if (pe.getType() == Xml.START_TAG && pe.getName().equals( "Coordinates" ) ){ pe = parser.read(); String coords = pe.getText(); } } // atr = pe.getAttribute( null, "lat" ); if( atr != null ) lat = atr.getValue(); // atr = pe.getAttribute( null, "lon" ); if( atr != null ) lon = atr.getValue(); } } index++; Debug.debug( "WP " + index + " name:\"" + nam + "\" desc:\"" + dsc + "\" lon:\"" + lon + "\" lat:\"" + lat + "\"" ); // wpdb.add( new Waypoint( new Coords( lon, lat, "-99999" ), new WaypointInfo( WaypointInfo.STYLE_DEFAULT, false, false, false, nam, idn, "", "", "" ), 0, WpSymbols.getId( typ ) ) ); } } trucking = ! ( pe.getType() == Xml.END_TAG && pe.getName().equals( "Document" ) ); } }