XML, the Perl Way




  perl wtr2_libxml


This code uses the XML::LibXML manpage to process the invoices. It uses a lot of XML::LibXML specific methods instead of using the DOM. This makes for nicer and safer code. XML::LibXML is a Perl wrapper on top of the libxml2 library, an XML/XPath/DOM/RelaxNG/... library written by Daniel Veillard for the Gnome project.

Instead of using navigation methods (getFirstChild) it relies mostly on findnodes and findvalue, which use XPath to select nodes to access.

The error message is built as text and then parsed using parse_xml_chunk. While this might not be the best method I found it really nice to use.

Overall the code was quite easy to write, all the extra goodies provided by XML::LibXML compared to the DOM are really useful and make it much easier to write compact and safe code.

My main gripe with XML::LibXML is that it is often unstable, as the Perl module tries to keep up with the development of the librarie. The problem is that libxml2 is so widely used that I find that it is often upgraded by unrelated software, which can then cause trouble to code that uses XML::LibXML.


Michel Rodriguez <mirod@xmltwig.com>


This code is Copyright (c) 2003 Michel Rodriguez. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Comments can be sent to mirod@xmltwig.com


the XML::LibXML manpage

Ways to Rome 2 - Kourallinen Dollareita: http://www.xmltwig.com/article/ways_to_rome_2/