PHP Tutorial : Create a RSS / XMLS Feed

Welcome,

In this tutorial I will show you how to create a basic rss / xml feed with php. Basically, if you know how to create a feed in notepad, wordpad or whatever text editor, this will be easy. The difference between creating a php xml / rss feed and a “normal” one it’s that you can do this feed dinamyc later, by extracting feed elements from a database such as MySQL.

<?php
$XMLoutput = "<?xml version=\"1.0\"?>
<rss version=\"2.0\">
<channel>
<title>PHP RSS XML FEED</title>
<link>http://www.exampledomain.com/RSS-XML-FEED.php</link>
<description>RSS Feed Description</description>
<language>en-us</language>
<pubDate>dd/mm/yy</pubDate>
<lastBuildDate>dd/mm/yy</lastBuildDate>
";
$XMLoutput .= " <item>
<title>A title here</title>
<link>Some link here</link>
<description>description goes here</description>
</item>";
$XMLoutput .= "</channel></rss>";
header("Content-Type: application/rss+xml");
print $XMLoutput;
?>
This entry was posted in Usefull PHP and tagged , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>