php 获取xml节点标签内容


$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');

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM