O'Reilly logo

Special Edition Using XML, Second Edition by - et al. David Gulbransen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Event Based Parsing with SAX Under Java

The most straightforward method of parsing XML under Java is with the Simple API for XML (SAX). This section provides examples of the use of SAX with the Java API for XML Processing and focuses on Java-specific issues. Refer to Chapter 15, “Parsing XML Based on Events,” for a more detailed introduction to SAX.

Creating a SAX Parser Instance

In order to parse XML documents with SAX, we first need a method to generate a parser that supports the SAX API. In JAXP, parsing with SAX is made available through the creation of an instance of the JAXP SaxParser class. Because of the extremely general nature of the Java APIs for XML Processing, this is a multistep process.

First, a SAXParserFactory needs to be generated. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required