1

我目前有一个 SOAP 调用的返回。

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:getMakeResponse xmlns:ns="http://ws.fds.com">
      <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>

我怎样才能把它变成一个像下面这样的数组,或者类似的东西?

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

感谢您提供的任何帮助!

4

2 回答 2

3

我发现这个 http://www.bin-co.com/php/scripts/xml2array/ 似乎工作得很好。

于 2009-12-24T00:46:09.980 回答
0

如果您使用本机 PHP SoapClient,则输出已经转储到 PHP 对象中...

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

看看 $output 对象,它应该有你想要的大部分......

于 2010-01-22T18:28:36.060 回答