1
正如你所看到的我已经在Stackoverflow上检查了一些其他的答案,但我只得到空白的结果。这是我到目前为止:PHP simplexml_load_file不解析
$city = simplexml_load_file('http://api.openweathermap.org/data/2.5/weather?q=Tijuana&mode=xml&appid=12fcd235af3a27a895aecb26bc957055');
echo $city['current']['city']['name'];
echo $city->current->city;
任何帮助,非常感谢。
试试这个'回声(字符串)$城市 - >城市[ “名称”];''simplexml_load_string'或'file'忽略根元素,它是'你的情况 –
最后一个问题current':萨赫勒,我可以得到第一个口袋的结果,但不是第二个...例如: <?php $ base_clima = simplexml_load_file('http://api.openweathermap.org/data/2.5/weather?q=Tijuana&mode = XML&的appid = 12fcd235af3a27a895aecb26bc957055' ); // print_r($ city); $ humedad =(string)$ base_clima-> humidity [“value”]; $ wind_v =(string)$ base_clima-> wind [“speed”] ['value']; >
<= '湿度:'???$ humedad '%'>
<= '风速:'。 $ wind_v .'Km/h'?>
–我不明白哪个第二口袋? –