in reply to Re: Confusion ,XML::SIMPLE with DATA:DUMPER
in thread Confusion ,XML::SIMPLE with DATA:DUMPER
Considering the data you need, there is no way for you to avoid storing the phone numbers, then outputing them when you find the reason. You could leave the elements (and just these elements) in the tree though, by using twig_roots to get the twig built only for them:
#!/usr/bin/perl use strict; use warnings; use XML::Twig; XML::Twig->new( # the twig will only contain PHONENO/ENTRY and REASON/ +ENTRY elements # (plus the root or it would not be a tree) twig_roots => { 'BL_USER/PHONENO/ENTRY' => 1, + 'BL_DPLI_RECORD/REASON/ENTRY' => \&rea +son, } ) ->parsefile( 'phone_data.xml'); sub reason { my( $t, $reason)= @_; foreach my $phone_no ($reason->prev_siblings) { print $phone_no->text, ";", $reason->text, "\n"; } $t->purge; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Confusion ,XML::SIMPLE with DATA:DUMPER
by ultibuzz (Monk) on Nov 21, 2006 at 09:06 UTC | |
by mirod (Canon) on Nov 21, 2006 at 12:47 UTC | |
by ultibuzz (Monk) on Nov 21, 2006 at 14:06 UTC |