What will the XML file look like, and what will the resulting table of
strings contain? Generally speaking, to use a SAX parser, you might
create a class that extends org.xml.sax.helpers.DefaultHandler. Then,
you execute the parser passing an instance of your handler class --
the parser reads the file and notifies your class whenever certain
things are encountered (like, a start element like <trk>, an end
element like </trk>, character data, white space, etc). The code to
execute the parser might look something like this if you've stored the
URL of the KML file in a string called url:
import java.io.InputStream;
import java.net.URL;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
SAXParserFactory spf = SAXParserFactory.newInstance();
YourSpecialHandler yourhandler = new YourSpecialHandler();
SAXParser sp = spf.newSAXParser();
InputStream s = new URL(url).openStream();
sp.parse(s, yourhandler);
result = yourhandler.getResult();
public class YourSpecialParser extends DefaultHandler {
public void startDocument() { }
public void startElement(String uri, String localName, String
qName, Attributes attributes) { }
//etc; see documentation for DefaultHandler
}
--Ben
On Sep 16, 5:04 am, sweet <[email protected]> wrote:
> Hello I'm new to android dev and I'd like to make a Parser xml which
> return a table of string, i've try to find a tuto in the net but
> without success. I know i should use SAX parser but i don't understand
> his working if anybody can explain to me it will be very nice or if
> anybody know a tutorial about this.
> Thanks a lot
> Sweet
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---