Hmm, Google Groups seems to interpret that inline XML text differently
than I expected, too (looked fine in preview). Let me try again. In
case this second try doesn't come out properly either, what I'm trying
to show is that the greater-than sign, the only text content of the foo
element, is written in escaped form in the embedded XML text in the
perl script (i.e., ampersand g t semicolon), but when it's printed by
XML::DOM, out comes just a plain greater-than sign (so XML::DOM is
writing malformed XML). What I want is for the escaped form (ampersand
g t semicolon) to be written as the content of the foo node.
Second try at my original post:
XML::DOM does not XML-escape text nodes' content on output. E.g., the
command
% perl -MXML::DOM -e 'print new
XML::DOM::Parser()->parse("<foo>&></foo>")->toString()'
prints
<foo>></foo>
and not, as I would like and expect,
<foo>&></foo>
Is there an easy way to simply XML-escape the content of all text
nodes, or something like that? (I can write a sub to do this myself, I
just figured there must be code for it already.)
It seems to do the right thing with attributes, BTW.