When should I use SAX?
The SAX API can provide faster and less costly processing of XML data when you do not need to
access all of the data in an XML document. The SAX API does the following:
- Accesses data through a series of events, eliminating the need to build a tree structure in memory. (As a result, speed of data retrieval is faster than with the DOM API because it is viewed as a flat document, or data stream.)
- Gives more control to the application by only parsing and returning the information it is asked for; the application builds the object model each time it parses the information.
- Allows you to access a small number of elements at one time rather than an entire document.
The SAX API is best for applications that need to access a specific piece of data and do not need to understand its relationship to surrounding elements. SAX is also ideal for information that is both generated by and readable by a machine. However, SAX cannot traverse the data, which makes it more expensive when you want to access data repeatedly from an XML document.
According to the http://www.saxproject.org website, SAX2 is a new version of Simple API for XML (SAX) that adds support for namespaces among other things. For more information about the SAX API at each of these levels, go to XML4C version 3.5.1 information.