views:

129

answers:

2

I currently have a return from a SOAP call.

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
  <soapenv:Body>
    <ns:getMakeResponse xmlns:ns="http://ws.fds.com"&gt;
      <ns:return>

        <ResponseCode>000</ResponseCode>  
        <ResponseDescription>No Errors</ResponseDescription>

        <MakeReturn>
          <Make>JEEP</Make>
          <MakeDescription>JEEP</MakeDescription>
        </MakeReturn>

          <MakeReturn>
            <Make>CHRY</Make>
            <MakeDescription>CHRYSLER</MakeDescription>
          </MakeReturn>

      <ns:return>
    </ns:getMakeResponse>
  </soapenv:Body>
</soapenv:Envelope>

How can I turn this into an array like below, or something similar?

Array
(
    [id] => 1
    [responsecode] => 000
    [responsedescription] => No Errors
    [0] => Array
        (
            [make] => JEEP
            [makedescription] => JEEP
        )
    [1] => Array
        (
            [make] => CHRY
            [makedescription] => CHRYSLER
        )
)

Thanks for any help provided!

+1  A: 

I found this http://www.bin-co.com/php/scripts/xml2array/ Which seems to work rather well.

Deuce
A: 

If your using the native PHP SoapClient the output already gets dumped into a PHP Object...

$client = new SoapClient('...wsAvailability.asmx?wsdl', array('trace' => true, 'exceptions' => 0));
$output = $client->GetWhateverMethod($input);
$xml = $client->__getLastResponse();

Look at the $output object, it should have most of what you want...

tomblin