RSS parser and generator, PHP and Ruby, CData

I was using Kouhei Sutou‘s rss lib to parse and generate a rss feed, it was running very well until I stuck with setting the CDATA value to description field. On Kouhei’s webpage it was said this lib started support content:encoded syntax since version 2.11. But my test found that it can read CDATA, not setting.

Emailed to Kouhei directly, got response pretty fast: I can’t do that.

OK, Ruby is too new to those stuff. I had to turn to php then.

Found 2 nice libs, lastRSS and feed generator, both are from Europe, fantastic tools, even neither of them has been updated since 2005.

The only glitch in feed generator is the default value of encoding, I had to hatch into its class module to change channel.encoding, the outside operation doesn’t work.

To set the CDATA using feed generator, syntax look like this:

$item->description = “asdfasfasf<br />asdfasdfa<br />”;
$item->descriptionHtmlSyndicated = true;

The generated rss xml will be:

<description><![CDATA[asdfasfasf<br />asdfasdfa<br />]]></description>

I have another problem using lastRSS, the fopen(rss_url) method only works locally, not on my DH shared host, maybe the allow_url_open is off by default on DH? I didn’t spend too much time on it because I switched to curl to work around immediately. I will look into this setting later.

LastRSS does not support ATOM, so I use famous MagpieRSS instead for an ATOM feed. There is only one thing I don’t like MagpieRSS is, it only reads feed from url, while lastRss can read both from url and file.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s