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; } 
3
  • 1
    unable to reproduce: eval.in/207547 Commented Oct 18, 2014 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. Commented Oct 21, 2014 at 9: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. Commented Oct 21, 2014 at 9:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.