XML::Twig Cleanly Picks Elements Off of XML Documents
Dave Aiello wrote, "I've been working with Amazon Web Services again recently. In the course of doing so, I found that using regular expressions to extract elements (data fields) from XML documents doesn't work reliably. I looked through my copy of
Perl & XML and saw reference made to a number of XML processing modules. For example: XML::Parser, XML::LibXML, XML::XPath, XML::Writer, XML::SAX, XML::Simple, etc."
"My task was to extract only a few elements from each XML document. Some of the documents contained sets of nodes, so they would have multiple instances of the same node."
"The easiest, most efficient, and most "perlish" way of handling this turned out to be using XML::Twig. I found a really good article about XML::Twig on XML.com. It does the job and provides the kind of TMTOWTDI that experienced Perl users expect from a Perl module."
"Perl and XML is a very good book, but, it's surprising that a module as useful as XML::Twig was left out of it. I'd recommend taking a fresh look at all the Perl XML modules whenever you set out to solve a type of XML problem that's new to you."