At this point, you should at least be comfortable with the mechanics of SAX and the ContentHandler interface. You've seen how events in a document parse are associated with specific callback methods in this handler, and how insertion of code in those callbacks is the means by which a SAX programmer interacts with XML data. However, understanding theory is hardly enough to write a useful program. To make this theory practical, this tip will demonstrate some realistic uses of SAX; I'll focus primarily on elements and textual data, as these are the most common use-cases of XML.
If you've been following along with this series of tips, you may be expecting to read about the SAX ErrorHandler interface -- that's what I promised at the end of the last tip, and that was certainly my intention. However, I've received several requests and suggestions for coverage of one last aspect of the ContentHandler interface, which of course I've been discussing for several tips now. Since the request was a good one, and involved another very common part of XML processing, I thought it was worth dealing with now. (For those of you who are just pining over error handling and the like, I hope you can hang on until my next tip!)