anniyan has asked for the wisdom of the Perl Monks concerning the following question:
Yesterday i asked a question xml::Twig partial_path question regarding path depth, and i got the answer in which they said to use something like this $epath = '<chap/<ch/<sec//<anchor'; , but i am getting error. where am i going wrong?
use XML::Twig; $str ='<chap> <ch> <sec> <p> <anchor>THE ILIAD</anchor> <author>HOMER</author> </p> </sec> <sec> <p> <anchor>BOOK I</anchor> <para> Sing, O goddess, the anger of Achilles son of Peleus, that brought countless ills upon the Achaeans. </para> </p> </sec> </ch> </chap> '; $epath = '<chap/<ch/<sec//<anchor'; $relt = 'anchors'; $epath =~ s/<//g; my $twig = XML::Twig->new( twig_handlers => { $epath => sub { normal (@_, $relt)}, pretty_print => 'indented' ); $twig->parse("$str"); #$twig->print; sub normal { my ($twig, $elt, $relt) = @_; $elt->set_gi( "$relt" ); #$elt->print; }
Error: unrecognized expression in handler: 'chap/ch/sec//anchor' at D:\ver\co +nversion.pl line 132
Regards,
Anniyan
(CREATED in HELL by DEVIL to s|EVILS|GOODS|g in WORLD)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Twig question
by mirod (Canon) on Nov 24, 2005 at 11:02 UTC | |
by anniyan (Monk) on Nov 24, 2005 at 11:11 UTC | |
by mirod (Canon) on Nov 24, 2005 at 17:35 UTC | |
by anniyan (Monk) on Nov 25, 2005 at 11:30 UTC | |
|
Re: XML::Twig question
by murugu (Curate) on Nov 24, 2005 at 11:50 UTC |