Subject: | hyphen in tag name causes wrap_children() not to match tags |
I am using wrap_children() to match a sequence of tags. If those tags have a hyphen in their tag name:
$_->wrap_children('<example-line>', WITHDASH => {}) for $twig->descendants('topic');
then the match does not work:
<example-line>foo</example-line>
<example-line>foo</example-line>
If the tags have no dash:
$_->wrap_children('<exampleline>', NODASH => {}) for $twig->descendants('topic');
then the match works:
<NODASH>
<exampleline>foo</exampleline>
</NODASH>
<NODASH>
<exampleline>foo</exampleline>
</NODASH>
Subject: | test.pl |
#!/usr/bin/perl
use strict;
use warnings;
use XML::Twig;
my $xhtml = <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<chapter>
<topic>
<p>line</p>
<example-line>foo</example-line>
<example-line>foo</example-line>
<p>line</p>
</topic>
<topic>
<p>line</p>
<exampleline>foo</exampleline>
<exampleline>foo</exampleline>
<p>line</p>
</topic>
</chapter>
EOF
my $twig=XML::Twig->new->parse($xhtml);
$_->wrap_children('<exampleline>', NODASH => {}) for $twig->descendants('topic');
$_->wrap_children('<example-line>', WITHDASH => {}) for $twig->descendants('topic');
$twig->print(pretty_print => 'indented');