XML::DOM::Twig
XML::DOM, The Perl Way
XML::DOM::Twig is an evil hack: it is a helper module that adds XML::Twig methods to XML::DOM.
I consider it evil because I hate XML::DOM and I think you should not be using it in the first place, there are plenty of good, Perlish modules on CPAN that are much nicer to use and better supported than XML::DOM. That said there are also a lot of people using XML::DOM for various reasons, ranging from the fact that it was one of the first Perl XML module to their boss saying "use the DOM"!. XML::DOM::Twig is designed to help those poor souls.
XML::DOM::Twig just adds a bunch of methods directly taken from XML::Twig to the usual DOM methods.
The most important addition, IMHO, is that navigation methods such as first_child or next-sibling now accept an additional argument, a condition, usually just a tag name, and will return an element with that name. $section->first_child( 'title') is much safer than $section->getFirstChild, which can return anything from the actual section title to the line return after the section tag or to a comment placed between the 2 start tags.
So please use this module, and send me back any comment at m.v.rodriguez@ieee.org. I am especially interested in additional methods that you would like to see ported from XML::Twig, whether you'd rather have it overload regular XML::DOM methods (adding optional arguments) instead of creating new ones, or whether you think I should just ditch the module and forget all about XML::DOM.
Note that there are 2 other helper modules for XML::DOM on CPAN:
- XML::DOM::BagOfTricks, provides a more perlish layer over XML::DOM, ,
- XML::DOM::XPath adds XPath support to XML::DOM.
Note also that XML::LibXML also implements the DOM (it is very easy to port code from XML::DOM to XML::LibXML, see Ways to Rome 2), but also lots of other standards, most importantly XPath, and in most case should be preferred to XML::DOM.
WARNING
XML::DOM::Twig is in ALPHA state (it is not even on CPAN yet). It is not well documented, not completely tested and by no means complete. Everything in it could be changed. Are you warned enough?
Links: [documentation] [XML-DOM-Twig-0.02.tar.gz] [browse] [changes] [README]