12

Is there any way to parse an XML string using Android SAX?

Rui Gonçalves
  • 2,423
  • 6
  • 30
  • 42
  • On the other hand you could just use the Simple library instead which is a million times better than SAX: http://massaioli.homelinux.com/wordpress/2011/04/21/simple-xml-in-android-1-5-and-up/ – Robert Massaioli May 05 '11 at 02:31

1 Answers1

18

Yes, first define a SAX ContentHandler:

class MyXmlContentHandler extends DefaultHandler {
   ... // implement SAX callbacks here
}

then you can use the Xml utility class:

Xml.parse(xmlString, new MyXmlContentHandler());
mxk
  • 43,056
  • 28
  • 105
  • 132