SAX Filters to the rescue
SAX parsers report content to applications as a series of events corresponding to document content. SAX filters take that information, do something to it, and pass it on to another process.
http://www.simonstl.com/articles/regfrag/saxfilter.html