Document Object Model (DOM), Simple API for XML (SAX) and Streaming API for XML (StAX) are populat APIs for processing XML documents.
The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML, and XML documents.
The entire XML document is read into memory and the nodes of the document are organized in a tree structure, called the DOM tree.
DOM allows for random access to the document.
DOM is bi-directional.
DOM can write XML documents.
SAX (Simple API for XML) is an event-driven online algorithm for parsing XML documents.
SAX parsers operate on each piece of the XML document sequentially; the application registers to receive events as entities are encountered within the source document.
SAX has a small memory footprint and is typically much faster.
SAX is not bi-directional.
SAX cannot write XML documents.
Streaming API for XML (StAX) is an application programming interface (API) to read and write XML documents, originating from the Java programming language community.
StAX was designed as a median between DOM and SAX.
In the StAX metaphor, the programmatic entry point is a cursor that represents a point within the document.
The application moves the cursor forward - 'pulling' the information from the parser as it needs.
This is different from an event based API - such as SAX - which 'pushes' data to the application - requiring the application to maintain state between events as necessary to keep track of location within the document.
StAX allows clients to start, pause and resume the parsing process.
Stax is bi-directional.
StAX can write XML documents.