I want to get the value of the following nodes:
ResponseMessage, Response Result and VelocitiHotLeadID
from this SOAP XML response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<SubmitHotLeadDetailsResponse xmlns="http://tempuri.org/">
<SubmitHotLeadDetailsResult xmlns:a="http://schemas.datacontract.org/2004/07/Velociti.Webservice.VelocitiHotLead" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ResponseMessage>1:VendorID Does Not Exist 2:IDNumber is invalid.</a:ResponseMessage>
<a:ResponseResult>false</a:ResponseResult>
<a:VelocitiHotLeadID>0</a:VelocitiHotLeadID>
</SubmitHotLeadDetailsResult>
</SubmitHotLeadDetailsResponse>
</s:Body>
</s:Envelope>
I've tried to use this code but it did not work:
$xml = simplexml_load_string($result, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/");
$xml->registerXPathNamespace('s', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('a', 'http://schemas.datacontract.org/2004/07/Velociti.Webservice.VelocitiHotLead');
$xml->registerXPathNamespace('i', 'http://www.w3.org/2001/XMLSchema-instance');
foreach($xml->xpath('//a:ResponseMessage') as $response)
{
echo $response;
}