Daniel's RSS feed Demo
This is a simple demo, please don't think it's real yet :)
Originally from: http://www.webmasterbase.com/article/560 No copyright on this code, but consult the original !)
This is feed is from a static page which is here:
http://tecfa.unige.ch/tecfa-people/schneider.rss ("View Source" if you can't see it)
Currently available from Daniel's feed
%s",
trim($link),htmlspecialchars(trim($title)));
printf("- %s
",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link, $rss_url;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($rss_url,"r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>