1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
<?php
class rss
{
var $item = FALSE ;
var $chem = '' ;
var $attribut ;
var $login ;
var $membre = array();
var $membre_existant = array();
var $existe;
function ouvre($sax, $nom, $attributs)
{
global $item, $chem, $attribut, $login, $membre, $membre_existant, $existe;
$this->chem .= '/'.$nom;
if ($this->chem=='/profil/item')
{
$this->login = '';
$this->item = TRUE;
}
}
function ferme($sax,$nom)
{
global $item, $chem, $attribut, $login, $membre, $membre_existant, $existe;
if ($this->chem=='/profil/item')
{
$login = utf8_decode($this->login);
if (in_array($login, $this->membre_existant))
{
echo 'La login ' . $login . ' se trouve dans les membres existant.<br />';
$existe=1;
}
else
{
array_push($this->membre_existant,trim($login));
$existe=0;
}
var_dump($this->membre_existant);
echo '<br /><br />';
if ($existe==0)
{
$membre []= array ('login' => trim($login));
}
}
$pos = strrpos($this->chem, '/');
$this->chem = substr($this->chem, 0, $pos);
}
function texte($sax, $texte)
{
if ($this->chem == '/profil/item/login')
{
$this->login .= $texte;
}
}
}
$url_flux= 'file.xml'; // url a modifier
$rss = new rss();
$sax = xml_parser_create();
xml_parser_set_option($sax, XML_OPTION_CASE_FOLDING, FALSE); // laisse le nom des balise en minuscule
xml_set_object($sax, $rss);
xml_set_element_handler($sax, 'ouvre', 'ferme');
xml_set_character_data_handler($sax, 'texte');
$fichier = html_entity_decode($url_flux, ENT_QUOTES, "UTF-8");
$fp = fopen($fichier, 'r');
while ($xml = fread($fp, 10000))
{
xml_parse($sax, $xml, feof($fp)); // On execute
}
xml_parser_free($sax);
?> |