Subject: | parse() and as_string() XML escaping issue |
XML::RSS's parse() (or parsefile()) decodes XML entities (like &), but then after adding another item and call as_string(), the decoded XML entities wouldn't encoded again in output XML.
Try this and you get a broken XML. Any known workaround for it?
(I use RSS version 0.91 for simplicity, it still happens when I use 1.0)
use strict;
use XML::RSS;
my $rss = XML::RSS->new(encoding => 'UTF-8', version => 0.91);
$rss->parse(<<RSS);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<title>example.com</title>
<link>http://example.com/</link>
<description>bla & blah</description>
<language>ja</language>
<item>
<title>foo & bar</title>
<link>http://example.com/</link>
</item>
</channel>
</rss>
RSS
;
print $rss->as_string;