php怎么取取xml里的数据?http://www.china-lz.org/
http://www.china-lz.org/
http://www.china-lz.org/
http://www.china-lz.org/
我想取http://www.china-lz.org/
里面path,smallinfo,url
放到数组里,我用$xml = simplexml_load_file('file.xml'),foreach $xml->pic 取不出来。
------解决方案--------------------
DOM解法:
$doc = new DomDocument();$doc->load("file.xml"); $lists=$doc->getElementsByTagName("list");foreach($lists as $list){ $path=$list->getAttribute("path"); $smallinfo=$list->getAttribute("smallinfo"); $arr[]=array('path'=>$path,'smallinfo'=>$smallinfo,'url'=>$list->nodeValue);}print_r($arr);<div class="clear"> </div>