SAX Overview

Unlike the DOM, SAX is not an object model. A SAX parser represents a document using events initiated sequentially while parsing the document tags. For example, the portion of the XML document demonstrated in Listing 15.1 will translate into the following sequence of events:

  • startElement

  • characters

  • endElement

Listing 15.1. Sample XML Document
...
<my-element>
    this is sample text
</my-element>
...
					

SAX Parsers

SAX is designed in such a way that it is very easy to use the API with different implementations of parsers. The only requirement is that parsers should implement a set of standard interfaces—otherwise, there is considerable freedom in implementing SAX-compliant parsers.

Currently, there are several implementations of SAX parsers ...

Get Special Edition Using XML, Second Edition 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.