rss20: Oops! You need to pass a URL!"; return false; } /* Use http object to retrieve raw RSS XML and to cache the data. Review class_http at http://www.troywolf.com/articles/class_http/ */ $h = new http(); $h->dir = "../../../../../cache/"; if (!$h->fetch($url, $ttl)) { /* The class has a 'log' property that contains a log of events. This log is useful for testing and debugging. */ echo "
\n"; #print_r($x->data); #echo "\n"; /* Now that we have the RSS data parsed into an object, here is how to work with it. */ #$version = $x->data->RSS[0]->_attr->VERSION; #$channel_link = $x->data->RSS[0]->CHANNEL[0]->LINK[0]->_text; #$channel_title = $x->data->RSS[0]->CHANNEL[0]->TITLE[0]->_text; echo "
RSS Example using class_http and class_xmlAuthor: Troy Wolf (troy@troywolf.com)Modified Date: 2005-06-27 16:25 The column shown on the right contains the top 5 news items from Google News. The news is syndicated using RSS. Thousands of websites from major news sites such as Yahoo and NPR to expert sites such as techreport.com to personal blogs provide their content in the RSS format making it easy for you to incorporate their content on your own website. This page is a demonstration of the rss20() function that combines the power of two PHP classes from Troy Wolf: View the source of this page which includes the rss20() function.
About the authorTroy Wolf is the author of SnippetEdit--a PHP application providing browser-based website editing that even non-technical people can use. Website editing as easy as it gets. Troy has been a professional Internet and database application developer for over 12 years. He has many years' experience with ASP, VBScript, PHP, Javascript, DHTML, CSS, SQL, and XML on Windows and Linux platforms. Check out Troy's Code Library.
|
/* Display the first 5 news items from Wired.com. Cache the news results for 5 minutes. */ #$url = "http://www.wired.com/news/feeds/rss2/0,2610,,00.xml"; $url = "http://news.google.com/?output=rss"; rss20($url, 300, 5); ?> |