How does php retrieve data in xml? & Lt ;? Xmlversion1.0encodinggb2312? ≫<imgList><pic><listpath"Publicimages01.jpg"smallpath"Publicimages01.png & quot; how does php retrieve data in xml?
Http://www.china-lz.org // </list>
Http://www.china-lz.org // </list>
Http://www.china-lz.org // </list>
Http://www.china-lz.org // </list>
6
I want Http://www.china-lz.org/</list> 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);