解析带有命名空间的XML导致致命错误

解析带有命名空间的XML导致致命错误,xml,xml-parsing,namespaces,Xml,Xml Parsing,Namespaces,我在使用registerXPathNamespace正确显示xml文件中的值时遇到问题。有人能指出我做错了什么吗?我不熟悉使用名称空间的XML 这是我正在使用的代码 $cpe = simplexml_load_file('test.xml'); $sxe=new SimpleXMLElement($cpe); $sxe->registerXPathNamespace('ipdr','http://www.ipdr.org/namespaces/ipdr'); $result0=$sxe

我在使用registerXPathNamespace正确显示xml文件中的值时遇到问题。有人能指出我做错了什么吗?我不熟悉使用名称空间的XML

这是我正在使用的代码

$cpe = simplexml_load_file('test.xml');

$sxe=new SimpleXMLElement($cpe);
$sxe->registerXPathNamespace('ipdr','http://www.ipdr.org/namespaces/ipdr');

$result0=$sxe->xpath('ipdr:IPDR->BulkData[0]')->Value;
$result1=$sxe->xpath('ipdr:IPDR->BulkData[1]')->Value;

echo $result0 ' <br> ' $result1; 
$cpe=simplexml\u load\u文件('test.xml');
$sxe=新的simplexmlement($cpe);
$sxe->registerXPathNamespace('ipdr','http://www.ipdr.org/namespaces/ipdr');
$result0=$sxe->xpath('ipdr:ipdr->BulkData[0]')->值;
$result1=$sxe->xpath('ipdr:ipdr->BulkData[1]')->Value;
回显$result0'
'$result1;
下面是XML文件test.XML

<ipdr:IPDRDoc xmlns:ipdr="http://www.ipdr.org/namespaces/ipdr"
xmlns="urn:broadband-forum-org:ipdr:tr-232-1-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:broadband-forum-org:ipdr:tr-232-1-0 tr-232-1-0-0-serviceSpec.xsd http://www.ipdr.org/namespaces/ipdr http://www.ipdr.org/public/IPDRDoc3.5.1.xsd"
docId="74697373-6f74-7878-7878-746973736f74"
creationTime="2013-06-11T05:52:55.153Z"
IPDRRecorderInfo="TEST IPDR Collector"
version="3.5.1">
    <ipdr:IPDR xsi:type="BulkDataReport">
    <BulkData>
        <Name>InternetGatewayDevice.DeviceInfo.UpTime</Name>
        <Value>1449</Value>
    </BulkData>
    <BulkData>
        <Name>InternetGatewayDevice.ManagementServer.URL</Name>
        <Value>www.yahoo.com</Value>
    </BulkData>
    </ipdr:IPDR >
    <ipdr:IPDRDoc.End count="1" endTime="2013-06-11T05:52:55.207Z"></ipdr:IPDRDoc.End>
</ipdr:IPDRDoc>

InternetGatewayDevice.DeviceInfo.UpTime
1449
InternetGatewayDevice.ManagementServer.URL
www.yahoo.com

我终于让它开始工作了。下面是我用来从text.xml文件中获取URL值的代码

$url = $xml->xpath("//ns:BulkData[ns:Name='InternetGatewayDevice.ManagementServer.URL']/ns:Value"); 
$url = $url[0];

我查看了相关的问题,发现了很多关于子元素有名称空间的情况的答案。在我的例子中,甚至根元素也分配了名称空间。这让我困惑。这是哪种语言?PHP?