You may also like to see:
- Which Perl module should I use to create a new XML file?
- Which Perl module should I use to modify an existing XML file?
- Which Perl module should I use to pull information from an XML file?
Jump to content
Which Perl XML module should I use?
Asked by brian_d_foy
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:
Answered by ruoso
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.
Answered by shlomif
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.
Answered by perigrin
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.
Answered by morungos
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.
Answered by Ron Savage
Posted Aug 14 2010 06:56 PM
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.
Answered by robinsmidsrod
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.
Answered by michelrodriguez
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.
Answered by Jim35
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>