XML::Twig constructor disregarding map_xmlns - bug in module?

  • Thread starter Andres Monroy-Hernandez
  • Start date
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 xmlns:prefix="http://perlmonks.org">
<prefix:foo>
<prefix2:bar xmlns:prefix2="http://perlmonks.org/blah">
<prefix2:monk>Larry Wall</prefix2:monk>
</prefix2:bar>
</prefix:foo>
</prefix:monastery>
XML

$twig->parse($xml);


Any ideas?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top