Subject: | XML::Twig 3.0.2 problem with setTwigHandler |
Never used this bug system, so if I don't hear something in
a day or so, I'll repost to perl-xml mailing list.
XML::Twig 3.0.2
perl, v5.6.1 built for i386-openbsd
When I run "testscript.pl 1" or "testscript.pl 2" everything works
as expected, but "testscript.pl 3" fails.
Kinda expected test '3' to work as well.
Am I missing something ? Do I have to specify at least one
handler in the initalizer ?
jerry@matilda.com
#!/usr/bin/perl
use strict;
use XML::Twig;
my $twig;
sub printit { $_[1]->print(); print "\n"; $_[0]->purge(); }
my $test=shift;
if ( $test eq "1" ) {
print "Running test 1..\n";
$twig= new XML::Twig(TwigHandlers=>{ '/books/book/name' => \&printit});
}
elsif ( $test eq "2" ) {
print "Running test 2..\n";
$twig=new XML::Twig();
$twig->setTwigHandlers({'/books/book/name'=>\&printit});
}
else {
print "Running test 3..\n";
$twig=new XML::Twig();
$twig->setTwigHandler('/books/book/name', \&printit);
}
undef($/);
$twig->parse(<DATA>);
exit(0);
__END__
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE books SYSTEM "books.dtd">
<books>
<book id="21714"><name>Book Title1</name></book>
<book id="21642"><name>Book Title2</name></book>
</books>