Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Fastest XML Parser ?

by mirod (Canon)
on Feb 17, 2008 at 06:26 UTC ( #668391=note: print w/replies, xml ) Need Help??

in reply to Fastest XML Parser ?

I maintain a series of benchmarks for various cases named Ways to Rome. The short answer is that the fastest parser is XML::LibXML.

In your case if XML::Simple is that slow, maybe that's because you are using it's default, pure Perl, parser which is really slow. Do you have XML::LibXML or XML::Parser installed? You might also need to set the $XML_SIMPLE_PREFERRED_PARSER (or $XML::Simple::PREFERRED_PARSER) to XML::Parser or XML::LibXML. See the Environment section in the docs of the module.

Replies are listed 'Best First'.
Re^2: Fastest XML Parser ?
by renodino (Curate) on Feb 17, 2008 at 20:16 UTC
    FWIW: $PREFERRED_PARSER should be XML::LibXML::SAX; just "XML::LibXML" falls down hard. And it did speed it up (0.4 secs vs. >1 sec). But XML::Simple's docs need a bit more clarity on the subject, cuz I tore out significant chunks of hair trying to find the secret sauce. (Not to mention the agony of setting up LibXML on Windows and fussing w/ environment variables so XML::LibXML could find it..).

    Perl Contrarian & SQL fanboy
      I agree that the docs could be clearer. Setting this variable causes code to die badly if the fast module is not installed.

      Here is code that I use to check if the fast module is installed. If it is installed, the code is happy, and it just uses the fast module. If it is not installed, it quietly falls back to the slow module:

      use English qw($CHILD_ERROR); use XML::Simple; # If a fast parser for XML::Simple is installed, then use it. my $parser = 'XML::LibXML::SAX'; my $cmd = "perl -M$parser -e 1"; my $output = qx($cmd 2>&1); unless ($CHILD_ERROR) { $XML::Simple::PREFERRED_PARSER = $parser; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://668391]
[Corion]: thezip: Quite good, after a one week vacation in the sun ;)
[Corion]: I hope you're well too!
[thezip]: Where did you go? We've already set a record for all-time February rainfall here.
[Corion]: thezip: The Canary Islands - they have a constant climate
[Corion]: Maybe a bit too many old people, but for some do-nothing vacation for R&R exactly the right thing ;)=
[thezip]: That's awesome. I bet you feel totally rejuvenated and ready for the next thing.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-02-23 17:01 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (349 votes). Check out past polls.