Mammouth du PHP |
504 Messages
26 mars 2012, 13:30
Je m'arrache les cheveux sur ce xml.
Code : Tout sélectionner
<?xml version="1.0" encoding="UTF-8"?>
<Slideshows>
<Slideshow>
<ID>7470120</ID> <Title>Oral cancer du sein</Title> <Status>2</Status><Created>Thu Mar 31 16:57:38 -0500 2011</Created> <Updated>Thu Mar 31 17:18:04 -0500 2011</Updated> <Language>fr</Language> <Format>ppt</Format> <Download>1</Download> <DownloadUrl>http://domaine.com/ppt-download/oralcancerdusein-110331165741-phpapp02.ppt?response-content-disposition=attachment&Signature=wgMHpIUGyoY4nwKbFciEPgPrOPg%3D&Expires=1332749418&AWSAccessKeyId=AKIAJLJT267DEGKZDHEQ</DownloadUrl> <SlideshowType>0</SlideshowType> <InContest>0</InContest>
</Slideshow>
<Slideshow>
<ID>7470382</ID> <Title>Oral cancer du sein</Title> <Description/> <Status>2</Status> <Created>Thu Mar 31 17:38:57 -0500 2011</Created> <Updated>Thu Mar 31 17:55:13 -0500 2011</Updated> <Language>fr</Language> <Format>ppt</Format> <Download>1</Download> <DownloadUrl>http://domaine.com/ppt-download/oralcancerdusein-110331173902-phpapp02.ppt?response-content-disposition=attachment&Signature=2y7hQOSb80mhnPtE9Fnm7vmDKP0%3D&Expires=1332749418&AWSAccessKeyId=AKIAJLJT267DEGKZDHEQ</DownloadUrl> <SlideshowType>0</SlideshowType> <InContest>0</InContest>
</Slideshow>
</Slideshows>
Et je veux le aprse sauf que les "&" m'en empeche.
J'ai essayé:
<?php
$Slideshows_xml = simplexml_load_file('test.xml');
$Slideshows_xml = str_replace("&", "&", $Slideshows_xml);
foreach ($Slideshows_xml ->Slideshow as $Slideshow) {
print "Nom de Slideshow:{$Slideshow->Title} <br />\n";
print "Id de Slideshow: {$Slideshow->ID} <hr />\n";
}
?>
ça ne marche pas.
Code : Tout sélectionner
<?php
$file=load('test.xml');
$dom = new DomDocument();
$dom->load($file);
$xpath = new DOMXPath($dom);
$arts = $xpath->query("/Slideshows/Slideshow/Title");
foreach ($arts as $art)
{
echo $art->nodeValue."";
}
?> ça non plus.
Bref, si quelqu'un a une idée c'est bien venu.
A noté que le xml de base est fourni par une API donc je ne peux pas le modifier.
La méthode consisterait à charger le xml, remplacer les "&" et parser le résultat.