March 30, 2012

How to display a link in <description> tag of rss feed

Question by Vinay

I am generating a rss(xml) output form a php file. I have got a link in <description> tag of rss file, I want a link to be displayed inside the description, I have written code as below.

<description><a href='http://www.google.com'>Google</a></description>

But its not displaying the link in the mozilla browser but in the IE, the text is getting printed without link, But google reader and feedburner says that it is not valid,

When I view the file source code, it looks as below

<description><a href=http://www.google.com>Google</a></description>

I know using below methods works

1) I know using htmlentities() function works, but when i view the source “<” replaced by "&lt;" , and “>” by "&gt;"

2) Using CDATA, Instructing the interpreter to not to parse the data enclosed in CDTA

In above cases the rss feed gets generated, As xml file is used to carry the data and not any presentation information, So both the cases violates the xml concept

So. Is there any way to write a valid rss(xml) file.

Answer by Starx

Check how the feed of stackoverflow works. It uses the exact same way as you are using. There is something else causing the problem probably.

March 22, 2012

Automatically generate RSS feeds

Question by Sherwin Flight

I have information stored in a database that I want to use to create RSS feeds.

What is the best way to do this?

Also, are there any PHP library/functions that I can pass the data to and they will take care of ensuring that any characters that need to be encoded/stripped are dealt with?

Answer by Starx

PHP Universal Feed Generator is the one you are looking for.

It supports RSS 1.0, RSS 2.0 and ATOM

...

Please fill the form - I will response as fast as I can!