The Workings of SAX
The DOM, covered in the previous chapter, creates a tree-like structure of the parsed XML document in memory. This structure is very memory consumptive, but is very easy to visualize and simple to use programmatically. SAX takes a completely different approach to processing XML documents.
In essence, the SAX parser reads the XML document sequentially from start to finish, and along the way will invoke various callback methods when particular events occur. A callback is a method registered with the parser, written to enable the code to respond to events of interest to the programmer.
An example of a callback is the startElement() method. The SAX parser will invoke this method whenever an opening element tag is encountered. ...
Get JSP™ and XML Integrating XML and Web Services in Your JSP™ Application now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.