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.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

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