php对xml的操作非常简单,急急急
http://api.map.baidu.com/telematics/v3/weather?location=北京&output=xml&ak=gfPnxaaiPyNIhM7c3eZ1kmEL
这个得到xml 如何把currentcity节点的值赋给$city,循环检索weather_data下的所有节点,赋值给数组
------解决方案--------------------
功能简介图书的添加、修改、删除。 拥有权限者:管理员、添加人员 ·管理图书的订单及修改订单状态和网友对图书的评论。拥有权限者:管理员、查看人员 ·管理网站前台用户,可进行修改、删除操作。 拥有权限者:管理员 ·对后台管理员进行权限分配和添加、修改、删除管理员。 拥有权限者:管理员 ·对图书的大小分类进行添加、修
$url = 'http://api.map.baidu.com/telematics/v3/weather?location=北京&output=xml&ak=gfPnxaaiPyNIhM7c3eZ1kmEL';<br>$xml = simplexml_load_file($url);<br><br>echo $city = $xml->xpath('//currentCity')[0];<br>foreach($xml->xpath('//weather_data') as $r) {<br> $date = (array)$r->date;<br> $dayPictureUrl = (array)$r->dayPictureUrl;<br>}<br>var_dump($city, $date, $dayPictureUrl);北京object(SimpleXMLElement)#2 (0) {<br>}<br>array(4) {<br> [0]=><br> string(30) "周五(今天, 实时:24℃)"<br> [1]=><br> string(6) "周六"<br> [2]=><br> string(6) "周日"<br> [3]=><br> string(6) "周一"<br>}<br>array(4) {<br> [0]=><br> string(57) "http://api.map.baidu.com/images/weather/day/leizhenyu.png"<br> [1]=><br> string(51) "http://api.map.baidu.com/images/weather/day/yin.png"<br> [2]=><br> string(52) "http://api.map.baidu.com/images/weather/day/qing.png"<br> [3]=><br> string(52) "http://api.map.baidu.com/images/weather/day/qing.png"<br>}<br><br>










