This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

Paul's Time Sink

| Main | Albums |

« | »

Parsing RSS in PHP

Paul Westbrook | 18 June, 2004 09:02

I found this pretty cool project to display RSS feeds in PHP scripts. It is called Magpie RSS. It parses the rss feed, and then allows PHP to display it as you want.

It looks like it supports RSS 0.9 through RSS 1.0. It also parses RSS 1.0's modules, RSS 2.0, and Atom

Here is an example that I created of a php script parsing this blog.

There is another example of this that is availabe with PEAR. But it doesn't appear that XML_RSS has been updated as recently.


Here is the php from my example:

$url = "http://www.westbrooks.org/blog/rss.php?blogId=2&profile=rss20";
print "<h1>RSS parsing with mag pie</h1>n";


include ( "rss_fetch.inc" );

$rss = fetch_rss( $url );
echo "<h2><a href="" . $rss->channel['link'] . "">" . $rss->channel['title'] . "</a></h2>";
echo $rss->channel['description'];
echo "<p>";
echo "<ul>";
foreach ($rss->items as $item) {
  $href = $item['link'];
  $title = $item['title'];
  $description = $item['description'];
  echo "<li><a href=$href>$title</a></li>";
}
echo "</ul>";



Add comment

Topic

Text

Your name

Your email address

Your personal page (if any)




Powered by LifeType
Design by Book of Styles