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)