tags:

views:

135

answers:

1

I'm using PyRSS2Gen to generate an RSS feed. I've succeeded in extending it to add an extra element to each item in the RSS feed:

class FullRSSItem(PyRSS2Gen.RSSItem):

    def __init__(self, **kwargs):
        if 'content' in kwargs:
            self.content = kwargs['content']
            del kwargs['content']
        else:
            self.content = None
        PyRSS2Gen.RSSItem.__init__(self, **kwargs)


    def publish_extensions(self, handler):
        PyRSS2Gen._opt_element(handler, "content:encoded", '<![CDATA[' + self.content + ']]>')

However, self.content contains HTML tags and all of the angled brackets (including those in the <![CDATA part) are translated into &lt; and &gt; when the feed file is generated.

How do I add an extra RSS item element that contains HTML using PyRSS2Gen?

A: 

I eventually ditched the idea of using the CDATA wrapper and just had the full text be encoded. Seems to work.

Phil Gyford