Creating RSS feeds with SimpleXML
Friday, August 22nd, 2008I love RSS feeds. One just needs to take a look at my Google Reader to see that;
One of the best things about them is just how easy they are to make. Here is a quick example with PHP showing how you can create RSS feeds with the PHP5 module SimpleXML.
<?php
$items = array(
array(
"title" => "example",
"pubDate"=>2,
"link"=>"http://www.dougalmatthews.com"
"description"=>"post content")
);
header("Content-type: text/xml");
$rssName = "My RSS Feed";
$rssHomePage = "http://www.dougalmatthews.com/";
$description = "My RSS feed description";
$sxe = simplexml_load_string("<rss version=\"0.91\">
<channel>
<title>$rssName</title>
<link>$rssHomePage</link>
<description>$description</description>
</channel>
</rss>");
foreach($items as $item){
[...]
