attributes() 出错

WBOY
Release: 2016-06-20 12:40:29
Original
1205 people have browsed it

$oa=new DOMDocument();$oa->load("o.xml");
$a=$oa->getElementsByTagName("am")->item(0);
 foreach($a->attributes() as $x=>$y) {
   echo  $x; echo $y;
   }
我想要读取xml指定节点的所有属性名和值,
为什么会出错
Fatal error: Call to undefined method DOMElement::attributes()


回复讨论(解决方案)

DOMElement ::getAttribute 
SimpleXMLElement::attributes
两个不同的系统,不要弄混了

虽然有:
dom_import_simplexml
simplexml_import_dom
可以在两个系统间转换

但你也得先转再用吧

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!