tags:

views:

1023

answers:

5

I have tried many of the Perl XML Parsers. I was quite interested in the Sablotron Parser, but it is such a pain to install on a Windows box. Currently I have started using XML::LibXML and XML::LibXSLT both of which seem to do everything I need.

They seem to be quite standard as well. Are there any better XML Parsers to use than this?

+11  A: 

I think you are using a pretty good one. XML::LibXML, Matt Sergeant and Christian Glahn's Perl interface to Daniel Velliard's libxml2 is one of the faster XML Parsers that I know of.

Simucal
Thanks, just after clarification that I am using the right tool
Xetius
Yea. You definitely aren't using anything weird.. it is pretty close to standard.
Simucal
+6  A: 

If you need speed, power or features, XML::LibXML is the way to go. If you're after ease of use, though, XML::Simple is a viable alternative.

Joe Casadonte
Yes. Beware though: just because it's called Simple doesn't mean you're not supposed to read the documentation.
innaM
Indeed -- simple (as used here) is a relative term....
Joe Casadonte
Indeed. XML::Simple is probably one of the most featureful 'simple' parsing tools I've used in a long time. :)
Robert P
+3  A: 

In my experience XML::Simple is best for quick and dirty parsing of XML. We use it for parsing data from third parties that do not always conform to the XML standard. XML::Simple throws informative errors and gets you up an running extremely quickly.

aekeus
A: 

You could also look at XML::Liberal which uses LibXML underneath.

singingfish
+7  A: 

It really depends on your needs, as people have said. To parse XML files that were ~100Mb in size (gene annotations from TAIR, 1 file per chromosome), I used mirod's XML::Twig module, which lets you set callbacks to parse the elements that interest you, presenting each sub-document as an XML::Simple tree. It combines the benefits of a SAX parser (scanning the file as a stream) with a DOM parser (working more easily with the interesting pieces).