PHP5 SOAP XML 到数组中

发布于 2024-08-16 08:04:40 字数 1208 浏览 1 评论 0原文

我目前有 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
        )
)

感谢您提供的任何帮助!

I currently have a return from a SOAP call.

<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>

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剪不断理还乱 2024-08-23 08:04:40

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

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

查看 $output 对象,它应该具有您想要的大部分内容...

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文