http://qs321.pair.com?node_id=455143

I've noticed node ID is corrupting the xml generator for the RSS Feed.

Would it be possible that the <description> element in the feed be wrapped in a CDATA?

20050516 Edit by castaway: Changed title from 'rss xml generator'

Replies are listed 'Best First'.
Re: rss feed corrupted by certain nodes (control characters)
by tye (Sage) on May 09, 2005 at 19:43 UTC

    Unfortunately, XML 1.0 made some stupid decisions when it comes to handling things like "control characters". It appears that XML 1.1 removes this stupidity (well, restricts it to null characters).

    I've heard from at least one source that not even CDATA prevents this stupidity. I haven't tried to convince myself on this point by studying the standard but I'll note that the set of claims that I've heard from intelligent people who seem knowledgible about XML, confidently proclaimed, clearly contradict each other on the subject of how XML deals with control characters. I've sent people to go read the XML spec who returned and told me that I can use &#1; for CTRL-A in XML (no, you can't).

    I've advocated that we strip control characters from the XML we send out (by default, while allowing people to request it not be stripped, in part because so many "XML parsers" actually have no problem dealing with control characters). I don't see any other reasonable choices for what to do with control characters in PerlMonks XML, and that isn't for lack of looking; lots of different options looked promising but were eventually found unacceptable.

    Until someone implements that, you can strip the control characters before you hand the "XML" to your parser. Since this is a Perl programming site, I'd hope that most visitors won't find this particularly difficult to implement. Yes, I'd rather produce fully valid XML by default.

    See XML::Fling begone? for much more on this situation. Please read through that thread before replying in this thread.

    - tye        

      I hadn't checked properly, but I believe you are right XML doesn't accept control characters. Removing them by default, whilst also giving the option to request them, sounds like a good solution to me.