Anyone know of any Perl module to escape text in an XML document?
I\'m generating XML which will contain text that was entered by the user. I want to correctly handl
Although you better use a module like XML::LibXML or XML::Code you could wrap textual data in a CDATA section. You must only take care not to put ]]> in it (this sequence is also disallowed outside of CDATA sections!):
$text =~ s/\]\]>/]]>]]>";
$xml = "$text ";
As bonus your code will look more perlish obfuscated! :-)