O'Reilly logo

Beginning XML, 4th Edition by Andrew Watt, David Hunter, Linda McKinnon, Joe Fawcett, Eric van der Vlist, Jon Duckett, Danny Ayers, Jeff Rafter

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

Chapter 12. Simple API for XML (SAX)

In the last chapter, you learned about the Document Object Model (DOM) and how it can be used to work with your XML documents. The DOM is great when you work with relatively small documents that can easily fit into memory, but what do you do when you need to read an XML file that is several megabytes or even several gigabytes large? Loading this kind of data into memory can be very slow, and in many cases not possible. Luckily, you have another way to get the data out of an XML document: SAX.

This chapter covers the following:

  • What is SAX?

  • Where to download SAX and how to set it up

  • How and when to use the primary SAX interfaces

Note

Because SAX is an application programming interface (API), you need to learn some in-depth programming concepts within this chapter. As in the last chapter, you will learn it step by step, but you need to have some programming experience under your belt. In order to work through the many examples, this chapter explains how to download and install the Java Development Kit (JDK). If you do not plan to program applications for XML, but rather plan to use XML for its design- and document-driven nature, you may want to skip this chapter.

What Is SAX and Why Was It Invented?

The Simple API for XML, or SAX, was developed to provide a standardized way to parse XML and enable more efficient analysis of large XML documents. The problem with the DOM is that before you can use it to traverse a document it has to build up a massive in-memory ...

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