Welcome to WebmasterWorld Guest from 54.197.116.116

Forum Moderators: bill & werty

Message Too Old, No Replies

ERROR with HTML tags within RSS

How to convert html into xhtml in php to display in RSS feed?

   
8:33 am on Aug 10, 2009 (gmt 0)

5+ Year Member



I generate my RSS feed using php and they work fine with data without any html(data is dynamically dispayed from db).

When I try to display data with html tags like '<br>' the data is not displayed. I tried with some test xhtml data and it works fine.

Is there any way I can convert html into xhtml or any other solution to this?

I'm tryin out the 'Tidy' utility in PHP. but ur sujjestions are valued.

thanks in advance..

3:01 am on Aug 16, 2009 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



RSS is an XML file. It doesn't contain any HTML or XHTML per se. Entity-encoded HTML is allowed in the <description>. There are some examples [cyber.law.harvard.edu] provided at the RSS 2.0 Specification [cyber.law.harvard.edu].
9:17 am on Aug 17, 2009 (gmt 0)

5+ Year Member



wel i figured out that the issue is with embedding html within xml.

i tried including xsl. but didnt work.

1:03 am on Aug 18, 2009 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Where are you embedding this HTML? Are you using the entity encoding mentioned above?

Keep in mind that an RSS feed isn't meant to be presentational. You don't generally lay it out and design it like a web page. It's mainly for publishing data. If you want presentation, then make a web page.

3:51 am on Aug 18, 2009 (gmt 0)

5+ Year Member



thanks for the reply. well the data displayed in the description tag of the rss field is input by the users through a wysiwyg editor. so i can help the fact that the data to be displayed has html(say like tables). is there a solution for this?
3:52 am on Aug 18, 2009 (gmt 0)

5+ Year Member



above rss field = rss feed :)
3:53 am on Aug 18, 2009 (gmt 0)

5+ Year Member



and i meant to say i cant help the fact that the data has html. thanks
8:04 am on Aug 18, 2009 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



RSS 2.0 requires that you entity-encode all HTML in a feed (as per above). You would have to use a routine that parsed your input and then output entity-encoded HTML tags.
8:08 am on Aug 18, 2009 (gmt 0)

5+ Year Member



thanks for the reply. will try it out n post my status. thnx..
10:05 am on Aug 19, 2009 (gmt 0)

5+ Year Member



i used the PHP Function - htmlspecialchars() before outputting the html inside <description> tag and it works fine now. thnks for ur help
2:50 am on Aug 20, 2009 (gmt 0)

WebmasterWorld Administrator bill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



That's great news. Thanks for following up with your solution!