try{
if(!@$fluxrss=simplexml_load_file('http://localhost/gd_xml/bonsplans.rss.xhtml')){
throw new Exception('Flux introuvable');
}
if(empty($fluxrss->channel->title) || empty($fluxrss->channel->description) || empty($fluxrss->channel->item->title))
throw new Exception('Flux invalide');
echo '<h3>'.(string)$fluxrss->channel->title.'</h3>
<p>'.(string)$fluxrss->channel->description.'</p>';
$i = 0;
$nb_affichage = 1;
echo '<ul>';
foreach($fluxrss->channel->item as $item){
echo '<li>'
.(string)$item->description.
'<a href="'.(string)$item->link.'">'.(string)$item->title.'</a>
<i>publié le'.(string)date('d/m/Y à G\hi',strtotime($item->pubDate)).'</i>
</li>';
if(++$i>=$nb_affichage)
break;
}
echo '</ul>';
}
catch(Exception $e){
echo $e->getMessage();
}
ça fonctionne bien sauf que la balise XML description crache du HTML et je souhaiterais ne garder que l'image ou d'autres choses mais pas la totalité, voici l'architecture du XML :
<channel>
<atom:link rel="self" type="application/rss+xml" href="http://www.name/rss.rss"/>
<generator>lorem RSS Feed 2.0</generator>
<title>name :: Lesloremes</title>
<link>http://www.name.html</link>
<description> sur Internet</description>
<language>fr-FR</language>
−
<image>
−
<url>
http://www.name/images/logo.png
</url>
<title>name :: ff</title>
<link>http://www.name.com</link>
<width>144</width>
<height>98</height>
</image>
−
<item>
−
<title>
Awin (Boitier nu) -
</title>
−
<guid isPermaLink="true">
http:/name/cat1/
</guid>
−
<link>
http:/name/cat1/
</link>
<category>cat 1</category>
<pubDate>Thu, 21 Apr 2011 16:59:43 +0200</pubDate>
−
<description>
<div style="overflow:auto;"><div style="float:left;padding:5px;border:1px #dddddd dotted;"><a href="http://www.name/die-dedia/"><img border="0px" src="http://www.monimage.jpg" /></a></div><div style="float:left;padding:5px;border:1px #dddddd dotted;"><em><strong>1 pièce disponible
Létion.</strong></em><br/><br/>numérique haute définition qui combine les fonctionnalités TV par satellite (double tuner), radio et le potentiel qu'offre une connexion Internet avec la possibilité d'utiliser un disque dur poents TV et la lecture de [<a href="http://www.name/disque-dur-multimedia">...</a>] <ul><li>Tuner TNT liste : ellite DVB-S, </li><li>Capacité liste : Boîtier nu, </li><li>H.264 / MKV liste : Compatible H.264 / MKV, </li><li>WIFI liste : Wi-fi, </li><li>Type liste : Chipset Sigma Design SMP8634</li></ul><div style="float:left;padding:5px;border:1px #dddddd dotted;">Prix catalogue : 334,90 € TTC - </div></div><div/>
</description>
<source url="http://www.name/nouvdute.html">name</source>
</item>
j'avais pensé pouvoir le faire en Jquery, mais peut-être avez vous d'autres idées ?Merci par avance