Revision: 53546
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 27, 2011 09:17 by xmaestro
Initial Code
// 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', '[email protected]'); $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'); }
Initial URL
Initial Description
Generating RSS Feeds using SimpleXML in PHP
Initial Title
Generating RSS Feeds using SimpleXML in PHP
Initial Tags
Initial Language
PHP