Here is the response in SOAP:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://sdsds.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns0:ServiceResponse xmlns:ns0="ababa.co.ke/Schemas/SAFService.xsd">
<ns0:ResponseHeader>
<ns0:ResponseCode>1</ns0:ResponseCode>
<ns0:ResponseMsg>999</ns0:ResponseMsg>
</ns0:ResponseHeader>
</ns0:ServiceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And now I am trying to get ResponseCode value as below
//not working
$obj = simplexml_load_string($xml);
$result = $obj->body->ServiceResponse->ResponseHeader->ResponseCode;
echo $result[0];
print_r($result);
//not working
$foo = new SimpleXMLElement($xml);
$bar = json_decode(json_encode($foo));
print_r($bar);
Can you please help or correct me where am I doing worng?
2
Answers
Finally I have done with SimpleXMLElement & got output exactly what I wished.
Output will be
A Quick example of using a
namespace
when querying the SOAP response – done using regular DOMDocument and DOMXPath but should be fairly straightforward with SimpleXMLThis will simply yield:
update using SimpleXML