I need to know what is the best way to parsing XML file in android, I know there is 3 parser (XMLPullParser, Dom Parser and Sax parser) so whats the different between it and if there any code to do that.
Asked
Active
Viewed 320 times
1
-
1there are lots and lots of articales regarding this. – Hardik Joshi Oct 11 '12 at 06:32
-
http://stackoverflow.com/questions/8893392/android-dom-vs-sax-vs-xmlpullparser-parsing – 4b0 Oct 11 '12 at 06:37
2 Answers
1
Android training recommends XMLPullParser.
http://developer.android.com/training/basics/network-ops/xml.html
We recommend XmlPullParser, which is an efficient and maintainable way to parse XML on Android.
They also give some code examples.

RomanI
- 403
- 4
- 7
1
Sax Parser : Simple API of XML Parse node to node, using top-down traversing, parse without storing xml, Faster compared to Dom Manipulating of node like insertion or deletion is allowed. Needs SAXParserFactory
Dom Parser : Document Object Model Stores entire xml in memory before processing, traverse in any direction, Manipulating of node like insertion or deletion is NOT allowed. Needs DocumentBuilderFactory
Pull Parser: It provides more control and speed from the above two.

balaji
- 1,555
- 5
- 26
- 49