Location: PHPKode > projects > RSS Framework for PHP > dump.php
<?php error_reporting(E_ALL);
 * Dynamic Networks RSS Framework for PHP This is an example file on how to use
 * the framework. Please note that the referenced URIs in this file are fake and
 * do not point to an actual resource on the internet.
 * @author Gordon Oheim (hide@address.com)
 * @copyright Copyright 2005, Dynamic Networks
 * @link http://www.dynamicnetworks.de
 * @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License
 * @filesource
 * @version 1.1.0
	/* we will need our framework and the parser for this */
	$path = 'src/classes/';
	set_include_path(get_include_path() . PATH_SEPARATOR . $path);


	/* create new feed */
	$rss = new feed();

	/* create new channel */
	$channel = new channel();
	$channel->set_title ("Sample Channel");
	$channel->set_description ("This is a sample channel.");
	$channel->set_link (new url("http://dynamicnetworks.de/rss/sample.htm"));
	$channel->set_copyright("Copyright 2005 - Dynamic Networks");
	$channel->set_docs (new url("http://dynamicnetworks.de/projects/rssframework/docs"));
	$channel->set_language ("en");
	$channel->set_managingEditor (new email("hide@address.com", "Gordon Oheim"));
	$channel->set_rating ('PICS-Label: (PICS-1.1 "http://vancouver-webpages.com/VWP1.0/" l gen false by "hide@address.com" on "2005.01.19T04:03-0800" for "http://dynamicnetworks.de/rss/sample.htm" r (P 0 S 0 V 0 Com 0 Tol 0 Env 0 SF 0 Edu 0 Can 0 MC 0 Gam -1 ))');
	$channel->set_skipDays (array("MON", "FRI"));
	$channel->set_skipHours (array(0,1,2,3,4,5,6,23));
	$channel->set_ttl (60);
	$channel->set_webmaster (new email("hide@address.com", "Dynamic Networks")); 

	/* add an image to be displayed with the channel */
	$image = new image();
	$image->set_url (new url("http://dynamicnetworks.de/rss/images/sample.gif"));
	$image->set_description("Sample Image");
	$image->set_height (35);
	$image->set_width (100);
	$image->set_link ($channel->get_link());
	$image->set_title ($channel->get_title());
	$channel->set_image ($image);

	/* set a category for the channel */	
	$category = new category("Coding Example");
	/* set another category with the same taxonomy */
	$category->set_title("RSS Feed");

	/* add a cloud to the channel */
	$cloud = new cloud();
	$channel->set_cloud ($cloud);

	/* add a textInput (useless as it is) to the channel */
	$desc = "Enter your comment here";
	$link = new url("http://dynamicnetworks.de/rss/comments/proc.php?id=samplefeed");
	$name = "comment";
	$title = "send comment";
	$textInput = new textInput($desc, $link, $name, $title);
	$channel->set_textInput ($textInput);

	/* add an item to the channel */
	$item = new item();
	$item->set_title("Sample entry number one");
	$item->set_description ("This is just a sample news item.");
	$item->set_link (new url("http://negative-infinity.de/rss/sample.htm#1"));
	$item->set_author(new email("hide@address.com", "Gordon Oheim"));
	$item->set_category($category);	// reusing from above
	$item->set_comments(new url("http://dynamicnetworks.de/rss/comments/proc.php?id=samplefeed"));
	$url = $item->get_link();
	$item->set_guid(new guid($url->get_url()));
	$item->set_source(new url("http://dynamicnetworks.de"));
	/* link an attachment to this item */
	$length =4096;
	$type = "application/zip";
	$url = new url("http://dynamicnetworks.de/rssframework/docs/framework_api.zip");
	$enclosure = new enclosure($url, $length, $type);
	$item->set_enclosure ($enclosure);
	/* alternatively you could use MediaRSS as a substitute */
	$mediaRSS = new mediaRSS();
	/* create a new mediaitem and add it*/
	$mediaitem = new mediacontent();
	$mediaitem->set_url(new url("http://www.example.com/audio/hooray_for_frameworks.mp3"));
	/* and another one */
	$mediaitem2 = new mediacontent();
	$mediaitem2->set_url(new url("http://www.example.com/audio/hooray_for_frameworks.mp3"));
	$mediaitem2->set_mediatext("This is the full version.");
	$mediaitem2->set_mediathumbnail(new mediathumbnail(new url("http://www.example.com/thumb2005.gif")));
	/* add some more mediastuff that applies to all mediacontent elements */
	$mediaRSS->set_mediathumbnail(new mediathumbnail(new url("http://www.example.com/thumb.gif")));
	$mediapeople = new mediapeople();
	$mediapeople->set_person("Joe Pro");
	$mediapeople->set_person("Jack Ducer");	
	$mediaRSS->set_mediatext("This is a MediaRSS test enclosure");
	/* dont forget to add the mediaRSS module to item*/

	/* and the item to the channel */
	$channel->set_item ($item);
	/* add another item to the channel but without an enclosure */
	$item2 = new item();
	$item2->set_title("Sample entry number two");
	$item2->set_description ("This is just another sample news item.");
	$item2->set_link (new url("http://negative-infinity.de/rss/sample.htm#2"));
	$item2->set_author(new email("hide@address.com", "Gordon Oheim"));
	$item2->set_category($category); // still reusing from above
	$item2->set_comments(new url("http://dynamicnetworks.de/rss/comments/proc.php?id=samplefeed"));
	$url = $item2->get_link();
	$item2->set_guid(new guid($url->get_url()));
	$item2->set_source(new url("http://dynamicnetworks.de"));
	$channel->set_item ($item2);
	/* set the pubDate of the channel to now */
	$channel->set_pubDate ();
	/* finally add the channel to the feed */
	 * we are all set now with the basics. Let's dump the feed object.
	$xml = new transformer();
	$dom = $xml->get_dom();
	$dom->dump_file("sample.xml", false, true);
	 * and now transform it into RSS20
	 $xml->transform($dom, "src/xslt/RSS20/to_rss20.xslt");
	 $dom->dump_file("feed.xml", false, true); 
	 * done! simple as that.
Return current item: RSS Framework for PHP