Question

Im trying to put an html embed code for a flash video into the rss feed, which will then be parser by a parser (magpie) on my other site. How should I encode the embed code on one side, and then decode it on the other so I can insert clean html into the DB on the receiving server?

Was it helpful?

Solution

Since RSS is XML, you might want to check out CDATA, which I believe is valid in the various RSS specs.

<summary><![CDATA[Data Here]]>

Here's the w3schools entry on it: http://www.w3schools.com/XML/xml_cdata.asp

OTHER TIPS

htmlencode/htmldecode should do the trick.

Ive been using htmlentities/html_entity_decode but for some reason it doesnt work with the parser. In a normal test it works, but parser always returns html code without < > " characters.

RSS is XML. It has very specific rules for encoding HTML. If you're generating it, I'd recommend using an xml library to write the node containing HTML, to be sure you get the encoding right.

HTMLencode will only perform the escaping necessary for embedding data within HTML, XML rules are more strict.

Instead of writing your own RSS XML feed, consider using the Django syndication framework from django.contrib.syndication:

https://docs.djangoproject.com/en/dev/ref/contrib/syndication/

It also supports enclosures, which is the RSS way for embedding images or video.

For custom tags, there is also an lowlevel API which allows you to change the XML: https://docs.djangoproject.com/en/dev/ref/contrib/syndication/#the-low-level-framework

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top