Summary
SAX and StAX are low-level streaming APIs that support efficient handling of XML documents. When parsing an XML document with SAX, events are generated and passed to the application, using callbacks to handlers that implement the SAX handler APIs. Because the events are low-level, the developer must maintain full document-state information to keep track of context during the parse.
DOM is a high-level parsing API, with a rich ability for navigating an in-memory tree representation of the XML. However, DOM’s utility and simplicity come at the price of performance penalties because the entire document must be parsed and stored in memory before any action can be taken.
In the next article, we’ll look at how SAX filters can be used to support staged processing of XML, as well as how StAX (a new breed of event parser) combines some of the best features of SAX and DOM.