demande d'aide sur XML et PHP

Par Hamza-Yassine ABOUABDILLAH, il y a 11 ans


salut
j'ai un API Weather ce forme XML
malheuresement je sais pas comment faire pour recupérer les donnes ce Format °C car il ya tempetrature Max et Min avec un type de solitude que je le connais pas

je veux afficher tous les temperature de 3 jours

le URL de XML: http://api.openweathermap.org/data/2.5/forecast/daily?q=Casablanca&mode=xml&units=metric&cnt=3

1 réponse

Hamza-Yassine ABOUABDILLAH, il y a 11 ans

voila mon code

<?php $dom = new DomDocument; $dom->load("http://api.openweathermap.org/data/2.5/forecast/daily?q=Casablanca&mode=xml&units=metric&cnt=3"); $listePays = $dom->getElementsByTagName('max'); foreach($listePays as $max) echo $temperature -> max->firstChild->nodeValue . "<br />"; $listePays = $dom->getElementsByTagName('min'); foreach($listePays as $min) echo $temperature->min->firstChild->nodeValue . "<br />"; ?>