Sunday 6 June 2010

Creating RSS Feeds with Plain display......

Here is the code for creating RSS Feeds in plain XML Feed format..
< ?php
header('Content-type: text/xml');

$feed_contents = "< !--XML Format RSS Feed for Website -- >";
$feed_contents .= "< listing>";
$feed_contents .= "< item>< name>Name 1 here< address>Address 1 here< /address>< /item>";
$feed_contents .= "< item>< name>Name 2 here< /name>< address>Address 2 here< /address>< /item>";
$feed_contents .= ''< /listing >";

$xml_filename = 'feed.xml'; // give the xml file path here
/* deleting the XML file if exists. */
if (file_exists($xml_filename)) {
unlink($xml_filename);
}
/* Writing the XML file. */
$file_handle = fopen($xml_filename, 'a');
fwrite($file_handle, $feed_contents);
fclose($file_handle);

echo $feed_contents;

?>

No comments:

Post a Comment

Please post any queries and comments here.