simplexml_load_file — Convertit un fichier XML en objet
Bonjour à tous,
J'ai besoin de votre aide s'il vous plait. Au fait, depuis plusieurs jours je cherche à convertir un lien externe (https://aviationweather.gov/adds/dat...tars.cache.xml) contenant du code xml en objet php afin de mieux le manipulé mais en vain.
Voici le message d'erreur qui s'affiche : Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Premature end of data in tag head line 1
Je ne sais vraiment pas comment contourner ce problème.
Quelqu'un saurait me dire ce qui coince ou me proposer une fonction qui pourrait m'aider à contourner ce problème?
voici mon code :
Code:
1 2 3 4 5 6
| $url = 'http://aviationweather.gov/adds/dataserver_current/current/metars.cache.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xmlresponse = curl_exec($ch);
$xml = simplexml_load_string($xmlresponse) or die("Error: Cannot create object"); |
Merci d'avance
Olivier