All this talk about HTML::Element made me remember: $elem->as_HTML
need to be told about CDATA elements. The textual content of these
elements should not be encode_entities()'ed on output.
The elements that need this treatment are:
<script>
<style>
<xmp>
<plaintext>
This is a small test program that shows the buggy behaviour of the
current HTML::Element:
-------------------------------------------------------->8-------
require HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new;
$tree->parse(<<EOT)->eof;
<title>Foo</title>
<script>
document.write("& å")
</script>
<h1>Heading with Å</h1>
EOT
print $tree->as_HTML;
-------------------------------------------------------->8-------
The <script> content becomes:
document.write("&amp; &aring;")
(at least if you have HTML::Parser v3)
Regards,
Gisle