- or download this
sub text_to_xml {
my $s = shift;
$s =~ s/]]>/]]>]]><![CDATA[/g;
return "<![CDATA[$xml]]>";
}
- or download this
use HTML::Entities qw( encode_entities );
sub text_to_xml {
return encode_entities($text, '<&');
}
- or download this
my %lkup = (
'<' => '<', # Not required.
...
$s =~ s/([<&"])/$lkup{$1}/g;
return qq{ $k="$v"};
}