How does php retrieve data in xml? & Lt ;? Xmlversion = '1. 0' encoding = 'gb2312 '? & Gt; & lt; imgList & gt; & lt; pic & gt; & lt; listpath = & quot;/Public/images/01.jpg& quot; smallpath = & quot; /How does Pu php retrieve data in xml?
Http://www.china-lz.org/
Http://www.china-lz.org/
Http://www.china-lz.org/
Http://www.china-lz.org/
6
I want Http://www.china-lz.org/ Path, smallinfo, url
Put it in the array, I use $ xml = simplexml_load_file ('File. XML'), and foreach $ xml-> pic cannot be retrieved.
------ Solution --------------------
DOM solution:
PHP code
$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);