Rasmus: [PHP] Parsing RSS
| From: | John Taylor-Johnston | Date: | Sun, 13 Aug 2006 03:47:08 +0000 |
| Subject: | Rasmus: [PHP] Parsing RSS | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240594@lists.php.net to get a copy of this message | ||
Thanks. P.S. excellent interview with Leo Laporte!
http://www.twit.tv/floss12
Your interview made me think of Cathedrals & Bazaars and the notion of free riders.
I've been much of a php free rider myself, but try to find ways to give back, usually through phpmyadmin.net
Thanks to everyone who give their time, and responses to my queries!
John
Rasmus Lerdorf wrote:
John Taylor-Johnston wrote:Is there something already created to open an rss file, parse it, and include() the useful stuff into an html file? Not all my students have an rss reader. http://jtjohnston.ca/jtjohnston.rssRSS is just XML. Use SimpleXML to map it to a PHP object and just print out whatever you want from it directly. eg. <?php $rss = simplexml_load_file('http://jtjohnston.ca/jtjohnston.rss'); $channel = $rss->channel; echo <<<EOB <img src="{$channel->image->url}" style="float: right;"/> <h1>{$channel->title}</h1> <h2>{$channel->description}</h2> EOB; foreach($channel->item as $item) { echo <<<EOB <h3><a href="{$item->link}">{$item->title}</a> ({$item->pubDate})</h3> {$item->description} <br clear="left" /> <hr /> EOB; } ?> Very ugly HTML markup there, of course, but add a bit of CSS and make it prettier. -Rasmus