To: | bug-XML-Twig [...] rt.cpan.org |
Subject: | subs_text generating entities sub's too much |
Date: | Tue, 12 Jul 2005 15:34:38 -0700 |
From: | ddascalescu [...] gmail.com |
I was trying to convert base entities back from their
expanded form into proper entities, using XML::Twig 1.213
2005/06/28 09:53:02, and failing that, I tried the subs_text
example from the development version documentation:
my $twig= new XML::Twig->parse("<p>gone\n still here</p>");
print "Before:\n", $twig->sprint;
$twig->subs_text( qr{ }, '&ent( " ")');
print "\n\nAfter: ", $twig->sprint;
It looks like subs_text replaces each character in the "gone"
string from the <p> element with an " " entity. If you
remove the "\n" from the text of the element, the substitution
will work properly.
The problem I had with the base entities was similar:
$twig->parse("<p>text\nthe newline causes < trouble.</p>");
print "\n\nBefore:\n", $twig->sprint;
$twig->subs_text(qr/</, '&ent( "<")');
print "\n\nAfter: ", $twig->sprint;
Hope this helps,
Dan Dascalescu