SAX parser vs XMLPull parser

Nelson Ramirez picture Nelson Ramirez · Apr 27, 2011 · Viewed 17.8k times · Source

I understand the difference between how the SAX parser works vs the XMLPull parser. In fact there's a pretty good explanation here:

http://www.firstobject.com/xml-reader-sax-vs-xml-pull-parser.htm The article is a bit .NET centric but the concepts apply.

While I agree with the author's opinion that the Pull parser is easier to work with, I'm pretty confused as to which type of parser would be better in which situations. If anyone could shed any light and point me to some more reading I would appreciate it.

Thank you.

Answer

Robert Massaioli picture Robert Massaioli · Apr 28, 2011

I find that they both suck. (And I have a better solution to suggest)

You should use the Simple annotation based XML library. I love it and use it for all of my projects. If you read through the tutorial then I think you will find that it will be able to do everything that you want and much faster and with less code. (Thus being less bug prone) Internally the library uses those parsers that you were asking about to do the heavy lifting.

You can then read my blog post on including it in an Android project if you want. (It will work in every version of Android from atleast 1.5 up which means for everybody basically)