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>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号