// create simplexml object
$xml = new SimpleXMLElement('<rss version="2.0" encoding="utf-8"></rss>');
// static channel data
$xml->addChild('channel');
$xml->channel->addChild('title', 'FRD Videos RSS Feeds');
$xml->channel->addChild('link', 'http://www.ste.com/feeds/');
$xml->channel->addChild('description', 'Latest Videos at FRD');
$xml->channel->addChild('language', 'en-us');
$xml->channel->addChild('webMaster', 'username@mailclient.com');
$xml->channel->addChild('generator', 'PHP SimpleXML');
$xml->channel->addChild('docs', 'http://www.site.com/videos.xml');
$xml->channel->addChild('pubDate', date(DATE_RSS));
// static channel data ( we get more from db in section below)
// query database for article data
...
// query database for article data
// Here we get more date from database for our xml
while ($row = mysql_fetch_assoc($result)) {
// add item element for each article
$item = $xml->channel->addChild('item');
$item->addChild('title', htmlentities($row['title']));
$item->addChild('link', 'http://www.site.com/'.$row['id'].'.html');
$item->addChild('description', htmlentities($row['description']));
$item->addChild('pubDate', date(DATE_RSS, strtotime($row['date_added'])));
}
// Here we get more date from database for our xml
// save the xml to a file
if($xml->asXML('videos.xml'))
{
header('Location:videos.xml');
}