Processing XML with SAX
SAX is the de facto standard XML parser interface for Java. You learn how to use it here with a simple SAX application written in Java.
The Simple API for XML (SAX) is a streaming, event-based API for XML (http://www.saxproject.org). It was (and continues to be) developed by members of the xml-dev mailing list (http://www.xml.org/xml/xmldev.shtml). Discussion of a uniform API for XML parsers began on xml-dev in December 1997 (http://lists.xml.org/archives/xml-dev/199712/msg00170.html) and resulted in the release of the first version of SAX in May 1998 (http://lists.xml.org/archives/xml-dev/199805/msg00226.html), with David Megginson as the chief maintainer (http://www.megginson.com/). SAX 2.0.1, which has namespace support, was released in January 2002, with David Brownell as the lead maintainer (http://lists.xml.org/archives/xml-dev/200201/msg01943.html).
SAX provides an interface to SAX parsers. As an event -based API, it munches on documents and
reports, parsing events along the way, usually in one fell swoop.
These reports come directly to the application through callbacks.
This is called push
parsing
. To push these events, an application
must implement event handlers (methods) from the SAX interfaces, such
as startDocument()
or startElement()
. Without implementing or registering these handlers, a
SAX application won’t
“see” the results that are pushed
up from its underlying parser.
Tip
Pull parsing , on the other hand, allows you to pull events on demand. ...
Get XML Hacks 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.