zacc has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking to retrieve certain RECORD elements from the file - which I can isolate using handlers without any problem (the code below is just a sample).<EXPORT> <OUTPUT>2008-01-01</OUTPUT> <RECORD>.....</RECORD> <RECORD>.....</RECORD> .... </EXPORT>
I was expecting to seesub record_check { my( $nhf, $record)= @_; my $member = $record->first_child('ID')->text; if ( $member <1000 ) { $nhf->flush(); print "\n"; } $nhf->purge(); } my $nhf= XML::Twig->new( twig_roots => { RECORD => 1, },twig_handlers +=> { RECORD => \&record_check,}, ); $nhf->parsefile( $input_file ); $nhf->purge;
but instead, if the first RECORD matches my query, I get<RECORD>...........</RECORD> <RECORD>...........</RECORD> ....
everything is OK if the first RECORD doesn't match.<EXPORT><RECORD>............</RECORD> <RECORD>...........</RECORD> ....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML Twig - Isolate Element
by GrandFather (Saint) on Jan 03, 2008 at 17:28 UTC | |
by zacc (Novice) on Jan 03, 2008 at 17:35 UTC | |
by GrandFather (Saint) on Jan 03, 2008 at 17:53 UTC | |
by zacc (Novice) on Jan 03, 2008 at 18:04 UTC | |
|
Re: XML Twig - Isolate Element
by mirod (Canon) on Jan 03, 2008 at 17:18 UTC | |
by zacc (Novice) on Jan 03, 2008 at 17:52 UTC | |
by mirod (Canon) on Jan 03, 2008 at 18:00 UTC | |
by zacc (Novice) on Jan 03, 2008 at 18:06 UTC | |
by mirod (Canon) on Jan 04, 2008 at 16:28 UTC |