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
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.
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 ...