0

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;
}
OtherDevOpsGene
  • 7,302
  • 2
  • 31
  • 46
maikelsabido
  • 1,253
  • 4
  • 18
  • 37
  • 1
    unable to reproduce: https://eval.in/207547 – hakre Oct 18 '14 at 19:00
  • @hakre sorry I don't get what you mean. hmmm.. I think you managed to display the output but I wanted to get the value within those nodes and put it in a variable which I could access later on. Could you help me on this? Thanks. – maikelsabido Oct 21 '14 at 09:07
  • Ah that was not clear to me you have a problem with that already. Please see the question I closed yours as a duplicate against. – hakre Oct 21 '14 at 09:29

0 Answers0