grRaSSbberSrc

default

grRaSSbber
Here is the PHP code:
<?php
error_reporting(E_ERROR);

$rssGrabber = urlencode($_POST['rssGet']);

if ($rssGrabber == '') {
	echo "<b>Enter a url of an rss feed</b>";
} else {
$rss = simplexml_load_file($rssGrabber);
echo "<h1>" . $rss->channel->title . "<hr></h1>";

foreach ($rss->channel->item as $eachItem) {
  print "<p>
  <span class=\"title\"><a href=\"$eachItem->link\">$eachItem->title</a></span><br>\n
  <span class=\"desc\">$eachItem->description</span><br>\n
  <span class=\"date\">$eachItem->pubDate</span><br>\n
  </p>
  ";
  }
}
?>


Notice the way the XML looks. There are different types of RSS. If the XML to your RSS has a different format then you need to adapt the PHP code.

Here is the RSS/XML code for the demo.
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>Test Rss Page</title>
<link>http://www.quitsendingmetrash.com/</link>
<description>This page is just here to test Reading an Rss Feed with php.</description>
<language>en-us</language>
<copyright>copyWhere</copyright>
<pubDate>Today</pubDate>
<lastBuildDate>Yesterday</lastBuildDate>
<category>php testing</category>
<ttl>60</ttl>
<image>
<title>nopic</title>
<url>http://www.quitsendingmetrash.com/nopic.gif</url>
<link>http://www.quitsendingmetrash.com/</link>
</image>
<item>
<title>PHP and XML RSS Grabber</title>
<link>http://www.quitsendingmetrash.com/lrn/web/php/grRaSSbber/grRaSSbber.php</link>
<guid isPermaLink="true">http://www.quitsendingmetrash.com/lrn/web/php/grRaSSbber.php</guid>
<description>grRaSSbber the PHP RSS Grabber. Just checking out the php simplexml functions. A friend wanted an RSS READER and it seemed simple enough.</description>
<pubDate>Wed, 06 Apr 2005 10:52:00 PST</pubDate>
</item>
<item>
<title>andien</title>
<link>http://www.quitsendingmetrash.com/lrn/web/php/andien/andien.php</link>
<guid isPermaLink="true">http://www.quitsendingmetrash.com/lrn/web/php/andien/andien.php</guid>
<description>The idea behind this project is to teach myself the how big endian and little endian formats work. The encoder reverses the order of letters in each word and then it swaps each pair of letters from left to right. The second letter becomes the first, the first the second, the fourth becomes third and third is fourth and so on for the length of the word. Odd numbered words leave the last letter in the same position.</description>
<pubDate>Mon, 14 Feb 2005 04:47:00 PST</pubDate>
</item>
<item>
<title>Bazier</title>
<link>http://www.quitsendingmetrash.com/lrn/director/bazier.php</link>
<guid isPermaLink="true">http://www.quitsendingmetrash.com/lrn/director/bazier.php</guid>
<description>bazier is a spaceship i made in lightwave. i exported to shockwave-[w3d] and then imported it into director and added lingo for control. i have not figured out how to wrap the spaceship from one side of the screen to the other. i am trying to figure out enough 3dLingo to turn this into a type of 3dAsteriods game.</description>
<pubDate>Mon, 08 Sep 2003 03:23:00 PST</pubDate>
</item>
<item>
<title>Hex to Decimal Chart</title>
<link>http://www.quitsendingmetrash.com/lrn/conversion/hexDecChart.html</link>
<guid isPermaLink="true">http://www.quitsendingmetrash.com/lrn/conversion/hexDecChart.html</guid>
<description>Simple hex to decimal chart.</description>
<pubDate>Fri, 28 May 2004 01:43:00 PST</pubDate>
</item>
</channel>
</rss>


grRaSSbber
default