Advertisement
6_2008-2009 Complete Applications #209458

RSS/XML News Feed Parser

This code parses an XML/RSS news feed document that resembles something like this feed: http://www.webfroot.co.nz/b2/b2rss.php. It makes each title a link to the actual article. Please see the image and/or http://members.lycos.co.uk/ctsirius/parse.php !

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<?
//The file to Parse, (i.e) Web Address.
$file = "http://www.webfroot.co.nz/b2/b2rss.php";
//Number of Bytes to Read. 10000 Should be Enough.
//Increase only if it does not read the entire file.
$byte = "100000";
//No more editing.
$ofile = @fopen("$file", "r");
$contents = @fread ($ofile, $byte);
@fclose($ofile);
if(!$contents)
{
echo "<p>\nUnable to Get XML/RSS data. Fatal Error.\n</p>";
exit;
}
preg_match_all ("'<title>(.*?)</title>'si", $contents, $titles);
preg_match_all ("'<link>(.*?)</link>'si", $contents, $link);
$count = count($titles[1]);
$link = $link[1];
$titles = $titles[1];
echo "<p>\n";
for($i = 0; $i <= $count; $i++)
{
echo "<a href=\"$link[$i]\">$titles[$i]</a>\n<br />\n";
}
echo "</p>";
?>
Original Comments (3)
Recovered from Wayback Machine