博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php 获取xml节点标签内容
阅读量:6998 次
发布时间:2019-06-27

本文共 449 字,大约阅读时间需要 1 分钟。

$arr 内容

<aaa>

<bbb Value="11111" Type="222"/>

<bbb Value="0000" Type="333"/>

</aaa>

 

$xml = new \DOMDocument(); $xml->loadXML($arr); $root = $xml->documentElement; $nodes = $root->getElementsByTagName("bbb"); //获取type222 $res[$nodes->item(0)->getAttribute('Type')] =$nodes->item(0)->getAttribute('Value');
//获取type333 $res[$nodes->item(1)->getAttribute('Type')] =$nodes->item(1)->getAttribute('Value');

 

转载于:https://www.cnblogs.com/niu6/p/8808918.html

你可能感兴趣的文章