login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > XML en PHP > RSS parser en reader (PHP5)

RSS parser en reader (PHP5)

Auteur: Tri - 08 januari 2005 - 15:07 - Gekeurd door: Dennisvb - Hits: 9468 - Aantal punten: 2.86 (7 stemmen)




Dit is een RSS parser en reader geschreven in PHP5.
Het script maakt gebruik van SimpleXML.

Tri

Code:
  1. <?
  2. /*
  3. July 2004
  4. RSS parser written in PHP5
  5. by Tri Pham
  6. (tri[at]tripham.nl)
  7. http://www.tripham.nl/
  8. */
  9.  
  10. /******************** ONLY EDIT THIS ********************/
  11. $rss_file = "link_to_rss_file"; // URL to rss file
  12. $max_headlines = 10; // How many headlines do you want?
  13. /******************** ONLY EDIT THIS ********************/
  14.  
  15. // Initialize SimpleXML
  16. $xml = simplexml_load_file($rss_file);
  17.  
  18. // $i is used for count
  19. $i=0;
  20. // Loop though
  21. foreach($xml->item as $item) {
  22.  
  23. if($i == ($max_headlines)){
  24. }
  25.  
  26. ++$i;
  27.  
  28. // Display headlines and description
  29. printf("<b><a href=%s>%s</a></b><br>", $item->link, $item->title);
  30. if(trim($item->description) == '') {
  31. // No description available
  32. printf("Description: unknown<br><br>");
  33. }
  34. else {
  35. printf("Description: %s<br><br>", $item->description);
  36. }
  37. }
  38. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Geen reacties (0)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.021s