createElement('rss'); $root = $doc->appendChild($root); $root->setAttribute('version','2.0'); //create the channel element $channel = $doc->createElement("channel"); $channel = $root->appendChild($channel); //define the elements of the channel and append them to the rss $elements = array(); $elements["title"] = "Radio Paradise Playlist -- Last 6 Hours"; $elements["link"] = "http://www.radioparadise.com/content.php?name=Playlist"; $elements["description"] = "The last six hours of music played by radioparadise.com. RSS generated by thousandrobots.com"; $elements["language"] = "en-us"; $elements["copyright"] = "copyright 2005 radioparadise.com"; $elements["docs"] = "http://backend.userland.com/rss"; $elements["generator"] = "thousandrobots.com dom-based rss generator (http://thousandrobots.com/projects/rp)"; $elements["managingEditor"] = "email@removethis.thousandrobots.com (ADM)"; $elements["webMaster"] = "email@removethis.thousandrobots.com (ADM)"; $elements["lastBuildDate"] = unix2rssdate(time()) . " PST"; foreach ($elements as $elementname => $elementvalue) { $elementname = $doc->createElement($elementname); $elementname = $channel->appendChild($elementname); $elementname->appendChild($doc->createTextNode($elementvalue)); } //clear the array unset($elements); //use simplexml to process the feed //and construct an element for each song foreach ($xml->song as $song) { $item = $doc->createElement("item"); $item = $channel->appendChild($item); //add each node of the rss item //title (song title) $element = $doc->createElement("title"); $element = $item->appendChild($element); $element->appendChild($doc->createTextNode($song->artist . ": " . $song->title)); //description $element = $doc->createElement("description"); $element = $item->appendChild($element); $element->appendChild($doc->createTextNode("played at: " . unix2rssdate($song->timestamp, "PST"))); //link $element = $doc->createElement("link"); $element = $item->appendChild($element); $element->appendChild($doc->createTextNode("http://www.radioparadise.com/content.php?name=songinfo&song_id=" . $song->songid)); //author $element = $doc->createElement("author"); $element = $item->appendChild($element); $element->appendChild($doc->createTextNode("info@radioparadise.com (". $song->artist . ")" )); //pubDate $element = $doc->createElement("pubDate"); $element = $item->appendChild($element); $element->appendChild($doc->createTextNode(unix2rssdate($song->timestamp) . " PST")); //category $element = $doc->createElement("category"); $element = $item->appendChild($element); $element->appendChild($doc->createTextNode("music")); //guid //technically not supposed to be a valid url, but some rss readers treat them as such. $element = $doc->createElement("guid"); $element = $item->appendChild($element); $element->appendChild($doc->createTextNode("http://www.radioparadise.com/content.php?name=songinfo&song_id=" . $song->songid)); } //output the xml/rss doc //note: when you want to output xml, //setting the content-type is mandatory -- even when debugging! header('Content-Type: text/xml'); echo $doc->saveXML(); } CreateRSSFeed(); ?>