O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

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

Basics of SAX Programming

SAX programming depends on recognizing events that occur during the process of parsing an XML document.

Parsing Events

In this section, you will use pseudocode to see what happens as an XML document is parsed using a SAX parser.

Listing 18.1 shows a short XML document that you will use to illustrate the SAX approach.

Listing 18.1. SAXSource.xml: A Short XML Document
<?xml version='1.0'?> 
<?xml-stylesheet href="myCSS.css" type="text/css" ?> 
<!-- This is an XML comment. --> 
<myDocument> 
Some text content. 
</myDocument> 

A SAX parser would respond to parsing an XML document like this by signaling events, similar to the following:

 start_document; processing_instruction; start_element (<myDocument>); characters; end_element ...

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