Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: XML parsing vs regex

by mirod (Canon)
on May 13, 2013 at 18:52 UTC ( #1033333=note: print w/ replies, xml ) Need Help??


in reply to XML parsing vs regex

With XML::Twig you don't have to load the entire tree in memory. You could do something like this (untested):

use XML::Twig; my $val; XML::Twig->new( twig_roots => { 'specificParentNode/nodeINeed' => s +ub { $val= $_->text; $_[0]->finish_now; } }) ->parsefile( "my.xml");

Only the NodeINeed would be in memory, and parsing would stop right after finding the value.


Comment on Re: XML parsing vs regex
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2015-07-04 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (58 votes), past polls