DOM and SAX provide two different approach to XML parsing.
In DOM parsers, the entire XML document is parsed into a tree and developers can use scripting to access parts of that tree. The point here is that the DOM parser needs to process the entire XML document. The document is retained in memory and can be accessed more than once.
SAX parsing is event-based and the XML document isn't retained in memory by the parser. As each event fires, the SAX parser can respond with an appropriate event handler created by the developer. It's argued that this is a much more efficient processing model.
The parser choice is determined by the XML application type. Simplistically, if a large XML document contains only a small amount of data to which an application needs to respond, it would make sense to use a SAX parser. If the application needs to repeatedly access content from the XML document, a DOM parser is appropriate.
Originally posted by KJ Reddy: How to take a decision on which parser to be used?
Sas has already talked about SAX and DOM. Stax is a pull based parser when you tell the parser to get the next XML token (element, string etc). It is easier to code using Stax. It can read larger XML documents and also be used to create XML document unlike SAX.Hope this helps.