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
I personally prefer XML::LibXML - Perl binding for libxml. One of the pros - it uses one of the fastest XML processing library available. Here is an example for creating text node:
use XML::LibXML;
my $doc = XML::LibXML::Document->new('1.0',$some_encoding);
my $element = $doc->createElement($name);
$element->appendText($text);
$xml_fragment = $element->toString();
$xml_document = $doc->toString();
And, never, ever create XML by hand. It's gonna be bad for your health when people find out what you did.