Java – Android: DOM vs SAX vs XMLPullParser parsing

androidjavaxmlxml-parsing

I am parsing XML Document using SAX Parser.

I want to know which is better and faster to work with DOM, SAX Parser or XMLPullParser.

Best Answer

it depends on what are you doing , if you have very large files then you should use SAX parser since it will fire events and releasing them ,nothing is stored in memory ,and using SAX parser you can't access element in a random way there is no going back ! , but Dom let you access any part of the xml file since it keeps the whole file/document in memory . hope this answer you question .

if you want to know which fastest parser Xerces is going to be the fastest you'll find and SAX parser should give you more performance than Dom