in reply to Operating on XML, or XML::Simple is too simple!

IMHO XML::Simple is used when you don't really care about the XML. Either you just use it as "just another storage format", or you just load it and use the data. Because you loose some information when you load data using XMLin, it is hard to get exactly what you want with XMLout.

If you really want to process XML documents you have to use a different kind of module, one which models the XML more faithfully than XML::Simple.

My recommendation would be to go either with XML::LibXML or with XML::Twig.

XML::LibXML is based on libxml2, which you have to install first (it should be already installed on most linux systems). It implements very rigourously a whole bunch of standards: XML, DOM, XPath... While the DOM is a bit of a pain to use (it is very verbose) you might already be familiar with it if you use Javascript, and the combination DOM + XPath is very powerful.

XML::Twig (which I wrote, so I might be a little bit biased ;--) is based on XML::Parser and on expat which you might have to install (it is already installed with Activestate Perl and on a lot of *nix systems). It is more perlish and concise than XML::LibXML but it doesn't implement as many standards, and the docs are... huge!

I would avoid XML::Parser at this point, it is not very well supported and is a bit too low level. You could also use some of the SAX modules, but they are probably not worth the pain unless you like low-level context management.

  • Comment on Re: Operating on XML, or XML::Simple is too simple!