获取多个命名空间xml的值 [英] get value of more than one namespace xml
本文介绍了获取多个命名空间xml的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi2 all
如果xml标签有多个命名空间值我只能得到第一个值
这就是我的意思
hi2 all
if the xml tag has more than one namespace value i can only get first value
here is what i mean
<?php
$xml = <<<XML
<?xml version="1.0" standalone="yes"?>
<people xmlns:p="http://example.org/ns" xmlns:t="http://example.org/test">
<p:person id="1">John Doe</p:person>
<p:person id="2">Susie Q. Public</p:person>
</people>
XML;
$sxe = new SimpleXMLElement($xml);
$namespaces = $sxe->getNamespaces(true);
var_dump($namespaces);
?>
返回
returns
array(1) {
["p"]=>
string(21) "http://example.org/ns"
}
i还需要
i need also
http://example.org/test
如何获得
how to get that
推荐答案
xml = <<<< XML
<?xml version = 1.0 standalone = yes ? >
< people xmlns:p = http://example.org/ns xmlns:t = http://example.org/test >
< p:person id = 1 > John Doe < / p:person >
< p:person id = 2 > Susie Q. Public < / p:person >
< / people >
XML;
xml = <<<XML <?xml version="1.0" standalone="yes"?> <people xmlns:p="http://example.org/ns" xmlns:t="http://example.org/test"> <p:person id="1">John Doe</p:person> <p:person id="2">Susie Q. Public</p:person> </people> XML;
sxe = new SimpleXMLElement(
sxe = new SimpleXMLElement(
xml);
这篇关于获取多个命名空间xml的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文