开发者

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

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜