A
Andres Monroy-Hernandez
XML::Twig seems to disregard the map_xmlns argument. The warn
"matched!" never get's called. If I remove the map_xmlns and hardcode
the prefixes, then it works. But the whole point is that I don't want
to hardcode the prefixes and map_xmlns is supposed to be just for
that.
use XML::Twig;
use strict;
my $twig = XML::Twig->new(
map_xmlns => {
"http://perlmonks.org" => 'aaa',
"http://perlmonks.org/blah"=> 'bbb'
},
TwigHandlers => {
'/aaa:monastery/aaa:foo/bbb:bar/bbb:monk' => sub { warn
"matched!"; $_[0]->purge; }
}
);
my $xml =<<XML;
<?xml version="1.0" encoding="UTF-8"?>
<prefix:monastery xmlnsrefix="http://perlmonks.org">
<prefix:foo>
<prefix2:bar xmlnsrefix2="http://perlmonks.org/blah">
<prefix2:monk>Larry Wall</prefix2:monk>
</prefix2:bar>
</prefix:foo>
</prefix:monastery>
XML
$twig->parse($xml);
Any ideas?
Thanks!
"matched!" never get's called. If I remove the map_xmlns and hardcode
the prefixes, then it works. But the whole point is that I don't want
to hardcode the prefixes and map_xmlns is supposed to be just for
that.
use XML::Twig;
use strict;
my $twig = XML::Twig->new(
map_xmlns => {
"http://perlmonks.org" => 'aaa',
"http://perlmonks.org/blah"=> 'bbb'
},
TwigHandlers => {
'/aaa:monastery/aaa:foo/bbb:bar/bbb:monk' => sub { warn
"matched!"; $_[0]->purge; }
}
);
my $xml =<<XML;
<?xml version="1.0" encoding="UTF-8"?>
<prefix:monastery xmlnsrefix="http://perlmonks.org">
<prefix:foo>
<prefix2:bar xmlnsrefix2="http://perlmonks.org/blah">
<prefix2:monk>Larry Wall</prefix2:monk>
</prefix2:bar>
</prefix:foo>
</prefix:monastery>
XML
$twig->parse($xml);
Any ideas?
Thanks!