[SimpleXML] Impossibilité de parser fichier xml
Posté : 24 août 2007, 02:16
Bonjour,
Je rencontre un problème pour lire un fichier xml via simplexml.
Pour parser le flux xml avec Simplexml, j'ai créer 2 fichiers : index.php5 et flux.xml
Dans le fichier index.php5, j'ai intégrer ce code :
Ce qui donne ceci :
Lorsque j'essaye de visualiser la page php, j'obtiens ces erreurs là :
Warning: simplexml_load_file() [function.simplexml-load-file]: flux.xml:4: parser error : EntityRef: expecting ';' in /home5/g/gsm-sonnerie/www/test/index.php5 on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: http://content.mkmb.net/p.ashx?id=748629&f=56&t=.mp3 in /home5/g/gsm-sonnerie/www/test/index.php5 on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home5/g/gsm-sonnerie/www/test/index.php5 on line 3
Vous pouvez voir le résultat à cette adresse :
http://www.gsm-sonnerie.com/test/index.php5
J'ai remarqué qu'il y avait un autre post similaire mais celà m'a pas aidé à résoudre mon problème.
Merci pour votre aide,
José
Je rencontre un problème pour lire un fichier xml via simplexml.
Pour parser le flux xml avec Simplexml, j'ai créer 2 fichiers : index.php5 et flux.xml
Dans le fichier index.php5, j'ai intégrer ce code :
<?php
$element = simplexml_load_file('flux.xml');
foreach($element->produit as $produit) {
echo 'Type de produit : ' ,$produit->ProductType.'<br>';
echo 'Titre de la sonnerie : ' ,$produit->Caption.'<br>';
echo 'Auteur : ' , $produit->Interpret.'<br><br>';
}
?>
Et dans le fichier xml, j'ai fais un copier coller du code xml généré avec un webservice de sonneries. Ce qui donne ceci :
Code : Tout sélectionner
<ArrayOfProduct>
<Product Id="748629">
<Localization>
http://content.mkmb.net/p.ashx?id=748629&f=56&t=.mp3
</Localization>
<Caption>Love today</Caption>
<CommandUrl>
http://nos-sonneries.magikmobile.com/culture/fr-FR/popup-redirect.aspx?q5=748629&p=53
</CommandUrl>
<ProductType>Hi-fi cd originale</ProductType>
<ProductTypeId>53</ProductTypeId>
<Interpret>Mika</Interpret>
</Product>
<Product Id="689507">
<Localization>
http://content.mkmb.net/p.ashx?id=689507&f=56&t=.mp3
</Localization>
<Caption>Parce qu'on sait jamais</Caption>
<CommandUrl>
http://nos-sonneries.magikmobile.com/culture/fr-FR/popup-redirect.aspx?q5=689507&p=53
</CommandUrl>
<ProductType>Hi-fi cd originale</ProductType>
<ProductTypeId>53</ProductTypeId>
<Interpret>Christophe Maé,Jacquot</Interpret>
</Product>
<Product Id="690576">
<Localization>
http://content.mkmb.net/p.ashx?id=690576&f=56&t=.mp3
</Localization>
<Caption>Je Me Bats</Caption>
<CommandUrl>
http://nos-sonneries.magikmobile.com/culture/fr-FR/popup-redirect.aspx?q5=690576&p=53
</CommandUrl>
<ProductType>Hi-fi cd originale</ProductType>
<ProductTypeId>53</ProductTypeId>
<Interpret>Kenza Farah </Interpret>
</Product>Lorsque j'essaye de visualiser la page php, j'obtiens ces erreurs là :
Warning: simplexml_load_file() [function.simplexml-load-file]: flux.xml:4: parser error : EntityRef: expecting ';' in /home5/g/gsm-sonnerie/www/test/index.php5 on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: http://content.mkmb.net/p.ashx?id=748629&f=56&t=.mp3 in /home5/g/gsm-sonnerie/www/test/index.php5 on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home5/g/gsm-sonnerie/www/test/index.php5 on line 3
Vous pouvez voir le résultat à cette adresse :
http://www.gsm-sonnerie.com/test/index.php5
J'ai remarqué qu'il y avait un autre post similaire mais celà m'a pas aidé à résoudre mon problème.
Merci pour votre aide,
José