XML-Atom-Stream
view release on metacpan or search on metacpan
lib/XML/Atom/Stream.pm view on Meta::CPAN
$self->{callback}->($feed);
}
}
my %Map = ('&' => '&', '"' => '"', '<' => '<', '>' => '>',
'\'' => ''');
my $RE = join '|', keys %Map;
sub encode_xml {
my($str, $no_cdata) = @_;
if (!$no_cdata && $str =~ m/
<[^>]+> ## HTML markup
| ## or
&(?:(?!(\#([0-9]+)|\#x([0-9a-fA-F]+))).*?);
## something that looks like an HTML entity.
/x) {
## If ]]> exists in the string, encode the > to >.
$str =~ s/]]>/]]>/g;
$str = '<![CDATA[' . $str . ']]>';
} else {
$str =~ s!($RE)!$Map{$1}!g;
( run in 0.584 second using v1.01-cache-2.11-cpan-454fe037f31 )