http://www.perlmonks.org?node_id=1033333


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.