RSS parser en reader (PHP5)
Auteur: Tri - 08 januari 2005 - 15:07 - Gekeurd door: Dennisvb - Hits: 9556 - Aantal punten: 2.86 (7 stemmen)
Dit is een RSS parser en reader geschreven in PHP5.
Het script maakt gebruik van SimpleXML.
Tri
|
Code: |
<?
/*
July 2004
RSS parser written in PHP5
by Tri Pham
(tri[at]tripham.nl)
http://www.tripham.nl/
*/
/******************** ONLY EDIT THIS ********************/
$rss_file = "link_to_rss_file"; // URL to rss file
$max_headlines = 10; // How many headlines do you want?
/******************** ONLY EDIT THIS ********************/
// Initialize SimpleXML
$xml = simplexml_load_file($rss_file);
// $i is used for count
$i=0;
// Loop though
foreach($xml->item as $item) {
if($i == ($max_headlines)){
exit;
}
++$i;
// Display headlines and description
printf("<b><a href=%s>%s</a></b><br>", $item->link, $item->title);
if(trim($item->description) == '') {
// No description available
printf("Description: unknown<br><br>");
}
else {
printf("Description: %s<br><br>", $item->description);
}
}
?>
<? /* July 2004 RSS parser written in PHP5 by Tri Pham (tri[at]tripham.nl) http://www.tripham.nl/ */ /******************** ONLY EDIT THIS ********************/ $rss_file = "link_to_rss_file"; // URL to rss file $max_headlines = 10; // How many headlines do you want? /******************** ONLY EDIT THIS ********************/ // Initialize SimpleXML $xml = simplexml_load_file($rss_file); // $i is used for count $i=0; // Loop though foreach($xml->item as $item) { if($i == ($max_headlines)){ } ++$i; // Display headlines and description printf("<b><a href=%s>%s</a></b><br>", $item->link, $item->title); if(trim($item->description) == '') { // No description available printf("Description: unknown<br><br>"); } else { printf("Description: %s<br><br>", $item->description); } } ?>
Download code (.txt)
|
|
Stemmen |
Niet ingelogd. |
|