Search the Community
Showing results for tags 'xml namespaces'.
-
Hello, I am going crazy trying to get the element values from XML file which contains elements with namespaces. Here is the XML file (test.xml) <?xml version = "1.0" encoding = "UTF-8"?> <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="IPDR Collector" version="3.5.1"> <ipdr:IPDR xsi:type="BulkDataReport"> <OUI>124BEB</OUI> <ProductClass>BGW</ProductClass> <SerialNumber>1234567890</SerialNumber> <Suspect>1</Suspect> <BulkData> <Name>InternetGatewayDevice.DeviceInfo.UpTime</Name> <Value>1449</Value> </BulkData> <BulkData> <Name>InternetGatewayDevice.ManagementServer.URL</Name> <Value>www.somesite.com</Value> </BulkData> </ipdr:IPDR > <ipdr:IPDRDoc.End count="1" endTime="2013-06-11T05:52:55.207Z"></ipdr:IPDRDoc.End> </ipdr:IPDRDoc> I am trying to get element values for BulkData Here is the code I am using and having problem with: $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; The result I am looking for should be : 1449 www.somesite.com Thanks for any help you can offer.