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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
soulmasta
Forum Newbie
Posts: 17
Joined: Fri Aug 15, 2008 4:50 pm

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

Post 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
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

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

Post 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.
soulmasta
Forum Newbie
Posts: 17
Joined: Fri Aug 15, 2008 4:50 pm

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

Post 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:
Post Reply