Logo classes.scriptsphp.org PHP

go to nav bar

RSS 0.91

Création et parsing de fichier RSS.

La classe RSS 0.91 fournit des fonctions permettant de parser ou de créer des fichiers RSS conformément aux spécifications RSS 0.91. Le parser utilise les fonctions XML de PHP, il est donc impératif que votre document ait une syntaxe XML valide.

Les Méthodes

Exemples

  1. Spécifications et DTD du format RSS 0.91
  2. Parser un fichier RSS - Affichage Simple
  3. Parser un fichier RSS - Affichage avancé
  4. Création d' un fichier RSS Simple
  5. Création d' un fichier RSS à partir d' infos venant de MySQL

Parser un fichier RSS - Affichage avancé

<?php
include('class.rss091.php');

$Ash = array ('http://classes.nte.com/syndication.php','i');

// le nombre de billet
$number 10;

$xml = new RSS;

$file $Ash[0];
$xml -> Parser($file);

$infos $xml -> return_infos('channel''item');
    
echo 
'<div class="rss">'."\n";
echo 
'<div class="channel">'."\n";
echo 
'<a href="'.$infos['channel']['LINK'].'">',htmlentities($infos['channel']['TITLE']),'</a>';
echo 
'</div>'."\n";
echo 
'<ul>'."\n";
    
$i 0;
foreach(
$infos['item'] as $val) {    
    
$val['LINK'] = preg_replace('`&(?!(?:amp;))`''&amp;'$val['LINK']); // entities xhtml
    
echo "\t<li><a href=\"$val[LINK]\" title=\"{$val['DC:DATE']}\">";
    if (
$Ash[1]=='u') { echo utf8_decode($val['TITLE']); }
    else { echo 
$val['TITLE']; }
    echo 
"</a></li>\n";
    if(
$i === $number) break;
    
$i++;
}

echo 
'</ul>'."\n";
echo 
'</div>'."\n";
?>

Merci de ne pas suivre ce lien emails.

0.9484s | «»
PHP powered