For example, you might want to print out just the contents of all of the
title elements in a document, or you might want to construct a complex data structure based on all of the information you find in the document. The SAX parser doesn't care; it just provides you with all of the data in the document in a linear manner so that you can do whatever you like with it.
You might be asking yourself at this point why you would ever care to parse an XML document at such a low level. In other words, why would you ever want to print out just the contents of the
title elements in a document? The main answer to this question has to do with data maintenance and integrity. As you continue to build and maintain larger and larger XML documents, you may find that you need to extract and study portions of the documents to find editorial errors or any other inconsistencies that are difficult to find when viewing raw XML code. A custom application built around a SAX parser can be used to drill down into an XML document and spit out any subset of the data that you want.