If you are up to PERL, use a real SAX parser:
PERL XML SAX Parser - Google Search
SAX is serial parsing, best for batch with potentially huge files. (The alternative, DOM, puts the entire XML file in memory as an object tree, impossible for bulk and for serial transmissions in real time.) It calls you as it traverses tags (elements), gives you direct access to attributes in and content after the start tag. It is up to you to manage state variables for where in the nesting you are.
In JAVA, I created a reusable object tree that reflected the XML syntax tree, with an abstract class to support an interface to support building classes for each type of element. PERL can probably do something similar. The PERL XML SAX lib probably has dictionary correctness checking as well, although I turned that off for speed and robustness and did my own validation.