开发者

PyRSS2Gen and embedding html in description tag

I want to format the content of the description using html tags. When I try to enclose the content in <![CDATA[content<p>here]]> it doesn't work properly, as it escapes some of the brackets, displaying O.K. in some RSS viewers, but displaying the ]]> in others.

If I try to avoi开发者_运维技巧d the CDATA and use escaped characters throughout, this mostly works, but $lt;p$gt; gets displayed as <p> rather than a new code.

Any thoughts?


According to examples in the RSS 2.0 specification you can use both CDATA and the escapes "Encoding & item-level descriptions".


I looked into my problem some more and the problem is that PyRSS2Gen uses python's sax library, which has no concept of CDATA, at least when writing out XML. My solution was just to drop PyRSS2Gen and directly use minidom, which does understand CDATA sections. That did mean some extra lines of code.

Once the html text inside my description tag was properly enclosed in a CDATA section, the raw xml looked fine and it also displayed the way I wanted it in 3 RSS readers I tried.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜