Why doesn't XML::RSS encode entities?

kellan on 2002-07-29T01:07:30

Why doesn't XML::RSS encode entities automatically when outputting XML? (or with a flag?) If I parse an RSS file with XML::RSS I get a nice datastructure out that I can tweak and play with, but if I want to pass that datastructure back into XML::RSS I have to worry about walking the mess of nested hashes, and re-encoding every stray ampersand.

Not so hard you say? True. Simply in fact. I can cut and paste lines 658 thru 897 out of XML::RSS and into my script, and then add a handful of calls to encode(). Somehow though, cutting and pasting 240 lines into my script seems the wrong way to go.

Is there a logic behind this that I'm missing? In general its a very nice module, and I feel like maybe I'm over looking a perfectly valid reason for building a tool that encourages broken XML.

Any insights appreciated. Thanks.


Entittitties

TorgoX on 2002-07-29T20:15:54

Why doesn't XML::RSS encode entities automatically when outputting XML?

I've wondered that, myself, many times. But I was (and am) too lazy to cook up a simple "see, look at this" test case to mail to the author.

Re:Entittitties

kellan on 2002-07-30T01:04:25

I think the author knows. Digging deeper on CPAN I found a 9 month old open bug on this very issue. The example case is pretty simple.
my $rss_in = new XML::RSS();
$rss_in->parsefile($file_containing_an_ampersand);


my $rss_out = new XML::RSS();
$rss_out->add_item( $rss_in->{'items'}[0] );
$rss_out->save('malformed_xml.rss');


I got email from someone who says they have a DWIM patch. If that falls through and I can't find a good reason for the current behaviour I'll write one.