Jump to content

Which Perl XML module should I use?

brian_d_foy's Photo
Posted Aug 14 2010 08:05 AM

There are many XML modules on CPAN. Which ones should I use for which tasks? Answer the poll but also reply with anything else that you want to share.

You may also like to see:

Poll: Which Perl XML module should I use? (22 members have cast votes )

Which Perl XML module do you like?

  1. XML::Twig (3 votes [11.54%] - View)

    Percentage of vote: 11.54%

  2. XML::Simple (3 votes [11.54%] - View)

    Percentage of vote: 11.54%

  3. XML::DT (3 votes [11.54%] - View)

    Percentage of vote: 11.54%

  4. XML::XPath (0 votes [0.00%])

    Percentage of vote: 0.00%

  5. XML::LibXML (13 votes [50.00%] - View)

    Percentage of vote: 50.00%

  6. XML::Easy (0 votes [0.00%])

    Percentage of vote: 0.00%

  7. XML::Compile (1 votes [3.85%] - View)

    Percentage of vote: 3.85%

  8. Other (3 votes [11.54%] - View)

    Percentage of vote: 11.54%

Vote Please sign or register to vote.

1 Subscribe

8 Replies

  ruoso's Photo
Posted Aug 14 2010 10:23 AM

XML::LibXML has a DOM interface, which is very usefull. It is also the base used by XML::Compile, which is, imnsho, the better way to handle well-formed, schema-based XML.
+ 1
  shlomif's Photo
Posted Aug 14 2010 10:57 AM

I'm using XML::LibXML almost exclusively with some help from XML::LibXSLT . XML::Simple is pure hate, XML::Parser is old-and-not-too-good, and XML::XPath was largely superseded by XML::LibXML's XPath functionality. XML::LibXML supports several interfaces including DOM/XPath, SAX and a pull parser.
  perigrin's Photo
Posted Aug 14 2010 11:16 AM

I am biased but I like XML::Toolkit and XML::SAX these days. It isn't an answer for everything but for what I do it is fun and works well.
  morungos's Photo
Posted Aug 14 2010 12:39 PM

XML::LibXML works great for me, although I also use XML::Parser::Expat when I really need SAX (for very big files). Main +ve about XML::LibXML is the very good XPath provision, which makes it real easy to find nodes and process them. XML::LibXSLT is also great, and has pretty good Perl integration, so you can write Perl functions and call them from XSLT -- if you ever needed to do that.
  Ron Savage's Photo
Posted Aug 14 2010 06:56 PM

Hi Folks

I use XML::SAX::ParserFactory, since I've decided to settle on SAX-style processing. To adopt this, you have to be comfortable with various aspects of the technique:

o Event-driven programming. An open tag and a close tag trigger events, so you write the code which handles those event. Between events, you have to accumulate the text between the tags.

o The size of the input file. I've never had a file so large I had to switch to XML::Twig, so SAX has been the way to go ever since I standardized on it.

o I like to store the results of processing each event in a giant hash, and the process it after having read the file (or sometimes, during the read). If you're not comfortable doing that, SAX is probably not for you.

  robinsmidsrod's Photo
Posted Aug 15 2010 12:14 AM

Shameless plug of my own module. I tend to use XML::Rabbit for processing XML because it uses an OO-based approach together with XPath to get at the actual data. It is obviously only useful for fetching data from XML, not for constructing it. It uses Moose and XML::LibXML's DOM parser and XPath support in the background.
+ 1
  michelrodriguez's Photo
Posted Aug 21 2010 05:41 AM

My take on this, and I am biased of course as the author of XML::Twig, is that there are 3 main choices:

- use XML::LibXML if you are doing "serious" XML processing, ie you don't mind using the DOM which is about the lowest level API you can imagine, or if you really need speed,

- use XML::Simple if you can get away with it, ie you only need to pull data out of XML files and it's all simple enough that XML::Simple works without having to read the docs in detail to get what you want (just read about the forcearray option),

- finally, use XML::Twig to get shit done: if you want something of a higher level than the DOM, with quite a bit of DWIM thrown in.

As a side note, lots of people were familiar with the DOM when they had to use it in Javascript, but now that everybody uses jQuery, it looks like that there might be room for a module like pQuery, but built on top of XML::LibXML
  Jim35's Photo
Posted Sep 03 2010 06:32 AM

XML::LibXML all the way, its much better.
<A HREF="http://www.articleden.com">do follow article directory</A>