1

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.

Mahmoud Jorban
  • 952
  • 4
  • 13
  • 25

2 Answers2

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