tags:

views:

554

answers:

1

why do we need xml parsing in android and which one is really better (SAX,DOM.PULL)

+9  A: 

I'm not sure why you're asking "Why do we need XML parsing in Android?" since the question seems to answer itself: to parse XML data. For example, there are many web services which return data in an XML format which will need to be parsed before you can use it in your application.

Here's an article at Developer.com comparing the performance of the DOM, SAX and Pull parsers on Android. It found the DOM parser to be by far the slowest, then the Pull parser and the SAX parser the fastest in their test. Here's another article at IBM that covers the three methods with sample code.

If you're going to be a doing a lot of parsing in your application it may be worth benchmarking the different options to see which works best for you.

Dave Webb
thank u dave..can u tell me which is the default browser in android.does it have one or should it be integrated
apoorva
Android comes with a Browser but to be honest I'm not sure I understand your question.
Dave Webb
not browser sorry i mean default xml parser
apoorva
All three parsers - SAX, DOM, Pull - come with the Android SDK. There isn't a default as such, just use the one which suits your requirements best. The SAX and Pull parsers perform better and use less memory so it's probably best to go with one of those. Have a look at code samples to see which one looks easier for you.
Dave Webb
thank u once again dave
apoorva