je fais appel à vous car j'ai pour habitude d'utiliserce ce bout de code pour parser des fichiers xml:
CODE
$site = "exemple.xml";
$fp = _AT_fopen($site,"r");
while(!feof($fp)) $raw .= _AT_fgets($fp, 4096);
fclose($fp);
if( eregi("<item>(.*)</item>", $raw, $rawitems ) ) {
$items = explode("<item>", $rawitems[0]);
for( $i = 0; $i < count($items)-1; $i++ ) {
eregi("<title>(.*)</title>",$items[$i+1], $title );
eregi("<url>(.*)</url>",$items[$i+1], $url );
eregi("<categorie>(.*)</categorie>",$items[$i+1], $cat);
echo "<li><a href='".$url[1]."'>".$title[1]."</a> - ".$cat[1];
}
}
$fp = _AT_fopen($site,"r");
while(!feof($fp)) $raw .= _AT_fgets($fp, 4096);
fclose($fp);
if( eregi("<item>(.*)</item>", $raw, $rawitems ) ) {
$items = explode("<item>", $rawitems[0]);
for( $i = 0; $i < count($items)-1; $i++ ) {
eregi("<title>(.*)</title>",$items[$i+1], $title );
eregi("<url>(.*)</url>",$items[$i+1], $url );
eregi("<categorie>(.*)</categorie>",$items[$i+1], $cat);
echo "<li><a href='".$url[1]."'>".$title[1]."</a> - ".$cat[1];
}
}
enfin bref jusque là tout va bien, mais je me trouve en ce moment devant un fichier xml qui a des attributs ds ses balises du genre:
CODE
<jolienewsaparser xsi:schemaLocation="http://www.jolienews.com/xml http://www.jolienews.com/monfichier.xsd" generation="2007-12-09T10:35:36">
<item Nom="nom1">
<channel Nom="nomchannel1" Ref="refduchannel" truc="trucduchannel">
lalalalilallaa
</channel>
<channel Nom="nomchannel2" Ref="refduchannel2" truc="trucduchannel2">
lalalalilallaalolololo
</channel>
<item Nom="nom1">
<channel Nom="nomchannel1" Ref="refduchannel" truc="trucduchannel">
lalalalilallaa
</channel>
<channel Nom="nomchannel2" Ref="refduchannel2" truc="trucduchannel2">
lalalalilallaalolololo
</channel>
donc ça va peut être vous paraitre tout simple pour certains mais moi ça fait quelques heures que je me creuse, que je cherche des exemples de flux parsés avec des attributs, mais je ne trouve pas.
Donc si vous avez une idée je suis preneur