Je me bats pour analyser un fichier XML en PHP:PHP et XML parsing
Voici le XML
<rss xmlns:ac="http://palm.com/app.catalog.rss.extensions" version="2.0">
<channel>
<title>Device App Updates for US</title>
<link>http://www.palm.com</link>
<description>Updates</description>
<language>en-US</language>
<pubDate>Mon, 04 Jan 2010 18:23:51 -0800</pubDate>
<lastBuildDate>Mon, 04 Jan 2010 18:23:51 -0800</lastBuildDate>
<ac:distributionChannel>Device</ac:distributionChannel>
<ac:countryCode>US</ac:countryCode>
<item>
<title><![CDATA[My App]]></title>
<link>http://developer.palm.com/appredirect/?packageid=com.palm.myapp</link>
<description><![CDATA[My fun app.]]></description>
<pubDate>2009-12-21 21:00:58</pubDate>
<guid>334.232</guid>
<ac:total_downloads>1234</ac:total_downloads>
<ac:total_comments>12</ac:total_comments>
<ac:country>US</ac:country>
</item>
</channel>
</rss>
Mon problème est; quand j'utilise:
$strURL = "http://developer.palm.com/rss/D/appcatalog.update.rss.xml";
$ch = curl_init($strURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$doc = new SimpleXmlElement($data, LIBXML_NOCDATA);
print_r($doc);
Je ne parviens pas à afficher les valeurs? Celui qui m'intéresse le plus est <ac:total_downloads>1000</ac>
mais je ne semble pas pouvoir l'analyser.
Qu'est-ce que je fais mal?
Un grand merci
Est-ce que $ data contient réellement le RSS? Que retourne 'print_r'? Pouvez-vous définir 'error_reporting (E_ALL);' et voir s'il y a des erreurs? –
Il n'y a pas d'erreur; tout fonctionne bien, mais il n'analyse simplement aucune des valeurs. –
Oliver