<?php
$fichier = 'http://www.phpfacile.com/demo/php/fluxrss.rss';
$dom = new DOMDocument();
if (!$dom->load($fichier)) {
die('Impossible de charger le fichier XML');
}
$itemList = $dom->getElementsByTagName('item');
foreach ($itemList as $item) {
$titre = $item->getElementsByTagName('title');
if ($titre->length > 0) {
echo $titre->item(0)->nodeValue;
} else {
echo '(sans titre)';
}
echo '<br />'."\n";
$desc = $item->getElementsByTagName('description');
if ($desc->length > 0) {
echo ' '.$desc->item(0)->nodeValue.'<br/>'."\n";
}
$lien = $item->getElementsByTagName('link');
if ($lien->length >0) {
echo ' <a href="'.$lien->item(0)->nodeValue.'">article complet</a>';
}
echo '<br/>'."\n";
}
?>
Les cours PHP
Apprendre PHP facilement
article complet
Les cours SQL
Apprendre SQL facilement
article complet
Les cours XML
Apprendre XML facilement
article complet