23.5. SAX Example 2: Counting Book Orders
One of the advantages of SAX over DOM is that SAX does not require you to process and store the entire document; you can quickly skip over the parts that do not interest you. The following example looks for sections of an XML file that look like this:
<orders> ... <count>23</count> <book> <isbn>0130897930</isbn> ... </book> ... </orders>
The idea is that the program will count up how many copies of Core Web Programming Second Edition (you did recognize that ISBN number, right?) are contained in a set of orders. Thus, it can skip over most elements. Since SAX, unlike DOM, does not store anything automatically, we need to take care of storing the pieces of data that are of interest. The one difficulty ...