how to parse local xml file in android using dom and sax?
Asked
Active
Viewed 1,446 times
1
-
Android simply provide a SAX parser for parsing. Go thru it on android developer site – Shaireen Dec 07 '11 at 07:53
-
@Shaireen what about DOM, doesn't Android provide DOM parsing? – Lalit Poptani Dec 07 '11 at 08:10
-
It does.. but SAX parser is used most of the times.For DOM chk http://www.androidpeople.com/android-xml-parsing-tutorial-%E2%80%93-using-domparser.. Apart from all dis XMLPULL Parser is also provided – Shaireen Dec 07 '11 at 08:14
1 Answers
1
Android provides a simple SAXParser for developers: http://developer.android.com/reference/javax/xml/parsers/SAXParser.html
So use the SAXParserFactory
to create a parser. Then use the sub class of DefaultHandler
to handle all parse events.
One more relevant class is the PullParser
:
http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html