Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

XML::LibXML vs XML::Parser and friends

by merlyn (Sage)
on Aug 29, 2003 at 13:57 UTC ( #287656=note: print w/replies, xml ) Need Help??

in reply to xml parsers: do I need one?

Adding my own experience to what's already been said here...

XML::Parser-based solutions (including XML::Simple) basically use C code to recognize tokens, but then have to build Perl data structures for the entire data tree, even for the parts that aren't being used.

XML::LibXML (if you can get it built and working, because it can be a bit finicky) builds the DOM as a C-side data structure. It's fast. Very fast. From the Perl side, you then ask for precisely the parts of the tree you want (with either DOM or XPath syntax), and only then are the heavyweight Perl objects created for those particular elements.

I've also seen benchmarks that libxml2 (on which XML::LibXML is based) is far faster at just recognizing the tokens than expat (on which XML::Parser is based). This also helps with speed.

I've pretty much abandoned any use of expat-based solutions now. XML::LibXML is it.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://287656]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-08-16 07:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found