Here is a solution using XML::Twig. Note that it relies on say being defined before vals (so when the handler on val is called the element say is already available.:
#!/usr/bin/perl -w -l use strict; use XML::Twig; my $t= XML::Twig->new( twig_handlers => { 'val[@val1="FOO"]' => sub { print $_->parent( 'monk')->fie +ld( 'say'); } } ) ->parse( \*DATA); __DATA__ <?xml version="1.0" encoding="ISO-8859-1"?> <monk value="PM"> <say>JAPH</say> <vals> <val val1="F" val2="value f"> </val> <val val1="FO" val2="value fo"> </val> <val val1="FOO" val2="value foo"> </val> <val val1="FOOB" val2="value foob"> </val> <val val1="FOOBA" val2="value fooba"> </val> <val val1="FOOBAR" val2="value foobar"> </val> </vals> </monk>
In reply to Re: XML::parser question
by mirod
in thread XML::parser question
by semio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |