Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Stepping up from XML::Simple to XML::LibXML

by sjf4 (Initiate)
on Apr 18, 2013 at 23:04 UTC ( [id://1029432]=note: print w/replies, xml ) Need Help??


in reply to Stepping up from XML::Simple to XML::LibXML

The version of XML::LibXML that's in RHEL5 (1.58) performs badly when performing findnodes on the results of findnodes for large XML files. The latest version from CPAN performs fine.
use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); foreach my $book ($doc->findnodes('/library/book')) { my($title) = $book->findnodes('./title'); print $title->to_literal, "\n" }
Here is my workaround for RHEL5:
use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); foreach my $book ($doc->findnodes('/library/book')) { my($title) = $book->getChildrenByTagName('title'); print $title->to_literal, "\n" }
Despite $book->childNodes returning only $book's child nodes, $book->findnodes appears to perform findnodes on the entire contents of $doc.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (None)
    As of 2024-04-25 00:53 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found