How to Create RSS XML feeds with PHP

February 16, 2006 | In WebTechnology | No Comments

Situation

You have data in a text file or mysql database and want to produce one of those cool RSS feeds you see on the canned sites and the big news sites.

Solution

The biggest trick is transforming the http headers sent to the web browser. You do this using the php header() function, changing header to text/xml.

header ('Content-Type: text/xml; charset=ISO-8859-1');

You can take a look at this sample script to see this in action.

To get Firefox to recognize that your page has a link to a RSS feed on the page, just add this to the page’s head:

< link rel="alternate" type="application/rss+xml" title="RSS" xhref="http://www.mydomainurl/thephpscriptname.php" mce_href="http://www.mydomainurl/thephpscriptname.php" />

Hope this helps someone.

Powered by WordPress RSS XMLRSS Feed - Syndicate this Site and comments feed
linux GNUpowered by Apache tomcatMySQL ABPHP - The Language the Web Runs on

^Top^ Gare CalhounGare CalhounGare CalhounGare CalhounGare Calhoun