Friday, June 18, 2004

Parsing RSS in PHP

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 = "";
print "<h1>RSS parsing with mag pie</h1>n";
include ( "" );
$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>";

No comments:

Post a Comment

Mastering Home Network Security: A Step-by-Step Guide to Fortify Your DNS with Pi-Hole and Raspberry Pi Across Multiple VLANs

Recently, I delved into the realm of setting up secure DNS for our home network, aiming to encrypt DNS requests en route to the name server....