Page 1 of 1

LastRss - How to parse the image from this xml feed ?

Posted: Mon Sep 22, 2008 7:46 am
by soulmasta
Hi
i need you help ,

am using lastrss parser and with the following part of code am parsing an xml feed from the web (rss url: http://www.weatherforecastmap.com/unite ... on/rss.xml) ,
all is ok with parsing just i can not understand how we can parse also the images from the feed ..?
parsing the text is allright just i cannot parse the image :(

Code: Select all

<?php
 
// On inclue lastRSS.php
include './lastRSS.php';
 
// Options de base
$url_flux_rss = 'http://www.weatherforecastmap.com/united_kingdom/london/rss.xml';
$limite       = 10; // nombre d'actus à afficher
 
// on crée un objet lastRSS
$rss = new lastRSS;
 
// options lastRSS
$rss->cache_dir   = './cache'; // dossier pour le cache
$rss->cache_time  = 3600;      // fréquence de mise à jour du cache (en secondes)
$rss->date_format = 'd/m';     // format de la date (voir fonction date() pour syntaxe)
$rss->CDATA       = 'content'; // on retire les tags CDATA en conservant leur contenu
 
// lecture du flux
if ($rs = $rss->get($url_flux_rss)) 
{
  for($i=0;$i<$limite;$i++)
  {
    // affichage de chaque actu
    echo '<strong>'.$rs['items'][$i]['pubDate'].'</strong> &middot; <a href="'.$rs['items'][$i]['link'].'">'.$rs['items'][$i]['title'].'</a><br />';
  }
}
else 
{
  die ('Flux RSS non trouvé');
}
 
?>
What i have to change in order to parse also the image from the current xml rss feed ..?

thank ya in advance

Re: LastRss - How to parse the image from this xml feed ?

Posted: Mon Sep 22, 2008 9:48 am
by Maugrim_The_Reaper
The image is part of a CDATA block in the description elements of the feed - so you can't have the library get it separately. You could load up the description HTML, pass it to something like PHP DOM (or just use a regex) to get the images URI.

Re: LastRss - How to parse the image from this xml feed ?

Posted: Mon Sep 22, 2008 3:37 pm
by soulmasta
Hello Maugrim_The_Reaper ,

i will be really thankfull if you can give an example on it ?! :?:
because my php nowledge is still limited :oops: