Summary

SAX, the Simple API for XML, is a Java native, parser-independent, event-based API for processing XML documents, suitable for use with very large documents and streaming data. SAX is organized mostly around interfaces. The implementation classes vary from one parser to the next.

The two key SAX interfaces are XMLReader, which represents the parser; and ContentHandler, through which the parser communicates with the client application. The client application registers its specific instance of the ContentHandler interface with an XMLReader through the setContentHandler() method. Then, as the XMLReader parses documents, it calls back to the methods in the ContentHandler object.

Only in the simplest programs do these callback methods give ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX 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.