My mistake! When I first wrote XML::Twig I only used it to output back XML. Outputting HTML or plain text came later. So there you have a bug!
The next version (XML::Twig 3.0) will fix this. I will properlly store the ' as... ' and only turn it into ' when using the print or sprint methods, the text one will leave it as '
In the meantime you can unescape the text using this:
sub unescape { my $text= shift; $text=~ s/</>/g; $text=~ s/>/</g; $text=~ s/"/"/g; $text=~ s/'/'/g; $text=~ s/&/&/; return $text; }
By the way, if you have tag-heavy XML you can also use CDATA sections: if you replace your string by the following one it will work (nearly, there is a definite bug there, as opposed to a poor design decision, which turns the & into &):
qq{<?xml version=\"1.0\"?><TEST><LINK><TITLE><![CDATA[This < is a > " test ' & don't you forget it]]></TITLE></LINK></TEST>}In reply to Re: Unescape characters from XML::Twig
by mirod
in thread Unescape characters from XML::Twig
by bpaulsen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |