I am trying to read the value of "SIM" via the below PHP code via the XML given below, but for some reason it gives me a blank "DOMNodeList" Any idea what i am doing wrong here ? I wanted to set that element as
<ns1:SIM old="8902"> 000000 </SIM> How do i do that, because I am trying with below code to find it but it seems output is "DOMNodeList" empty.
$xpath = new DOMXPath($doc); $xpath->registerNamespace('ns1', 'http://www.example.com/WSG/ec/'); $result = $xpath->query("/ns1:ModifySIMRequest/ns1:ServiceProfile/ns1:Primary/ns1:SIM"); foreach ($result AS $node) { var_dump($node); echo $node->nodeValue; } XML in $doc is
<?xml version="1.0"?> <ns1:ModifySIMRequest xmlns:ns1="http://www.example.com/WSG/ec/"> <ns1:ServiceProfile> <ns1:Speech> <ns1:MSN>33808089</ns1:MSN> <ns1:AccountNumber>8989895</ns1:AccountNumber> </ns1:Speech> <ns1:Primary action="mod"> <ns1:BillingOption>dsdsd</ns1:BillingOption> <ns1:SIM old="8902"/> </ns1:Primary> </ns1:ServiceProfile> </ns1:ModifySIMRequest>