I know you asked for a XML::Twig solution, but it would not be me if I did not suggest a XML::Rules one instead. It would be something like this:
use strict; use XML::Rules; my $parser = XML::Rules->new( stripspaces => 7, rules => { _default => 'content', Copyright => 'no content', # ... Record => sub { return unless $_[1]->{Title} eq 'Something'; print "The stuff in the %{$_[1]} hash containing the attributes an +d subtag data.\n"; return; } } ) $parser->parse($file);
The rules will allow you to ignore the subtags you do not need so they will not even take up memory. Plus you only ever have one <Record> in memory anyway. If the Record tag is more complex you may want to use the XML::Rules->inferRulesFromExample() to get the rules
In reply to Re: XML::Twig questions
by Jenda
in thread XML::Twig questions
by r1_fiend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |