in reply to XML Twig - Isolate Element
The following seems to do what you want:
use strict; use warnings; use XML::Twig; my $nhf = XML::Twig->new( twig_roots => { RECORD => \&record_check, }, + ); $nhf->parse(<<'XML'); <EXPORT> <OUTPUT>2008-01-01</OUTPUT> <RECORD><ID>1</ID></RECORD> <RECORD><ID>2</ID></RECORD> </EXPORT> XML sub record_check { my ( $nhf, $record ) = @_; my $member = $record->first_child('ID')->text(); if ( $member < 1000 ) { $record->print(); print "\n"; } $nhf->purge (); }
Prints:
<RECORD><ID>1</ID></RECORD> <RECORD><ID>2</ID></RECORD>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML Twig - Isolate Element
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 |