2017-07-18 76 views
0

我從Web服務,用肥皂這樣的返回數據:phpClient返回嵌套XML

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap-env:Header/> 
    <soap-env:Body> 
     <n0:ZFIFM_VIRTUAL_ACCOUNTResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions"> 
     <BILLDETAILS> 
      <item> 
       <BILLCODE>?</BILLCODE> 
       <BILLNAME>?</BILLNAME> 
       <BILLSHORTNAME>?</BILLSHORTNAME> 
       <BILLAMOUNT>?</BILLAMOUNT> 
      </item> 
      <item> 
       <BILLCODE>01</BILLCODE> 
       <BILLNAME>BIL</BILLNAME> 
       <BILLSHORTNAME>Billing</BILLSHORTNAME> 
       <BILLAMOUNT>114509000</BILLAMOUNT> 
      </item> 
      <item> 
       <BILLCODE>02</BILLCODE> 
       <BILLNAME>TAX</BILLNAME> 
       <BILLSHORTNAME>PPN 10%</BILLSHORTNAME> 
       <BILLAMOUNT>11450900</BILLAMOUNT> 
      </item> 
      <item> 
       <BILLCODE>03</BILLCODE> 
       <BILLNAME>TAX</BILLNAME> 
       <BILLSHORTNAME>PPL WAPU</BILLSHORTNAME> 
       <BILLAMOUNT>11450900</BILLAMOUNT> 
      </item> 
      <item> 
       <BILLCODE>04</BILLCODE> 
       <BILLNAME>TAX</BILLNAME> 
       <BILLSHORTNAME>PPK 4.2</BILLSHORTNAME> 
       <BILLAMOUNT>6758400</BILLAMOUNT> 
      </item> 
      <item> 
       <BILLCODE>05</BILLCODE> 
       <BILLNAME>TAX</BILLNAME> 
       <BILLSHORTNAME>PPJ 23 - 2%</BILLSHORTNAME> 
       <BILLAMOUNT>193500</BILLAMOUNT> 
      </item> 
      <item> 
       <BILLCODE>06</BILLCODE> 
       <BILLNAME>TAX</BILLNAME> 
       <BILLSHORTNAME>PPO 23 - 15%</BILLSHORTNAME> 
       <BILLAMOUNT>5587500</BILLAMOUNT> 
      </item> 
     </BILLDETAILS> 
     <BILLINFO1>1000000014</BILLINFO1> 
     <BILLINFO2>YOU MEAN IT</BILLINFO2> 
     <BILLINFO3>1140000000</BILLINFO3> 
     <BILLINFO4>JOJO Heart</BILLINFO4> 
     <CURRENCY>360</CURRENCY> 
     <STATUS> 
      <item> 
       <ISERROR>?</ISERROR> 
       <ERRORCODE>?</ERRORCODE> 
       <STATUSDESCRIPTION>?</STATUSDESCRIPTION> 
      </item> 
      <item> 
       <ISERROR>false</ISERROR> 
       <ERRORCODE>00</ERRORCODE> 
       <STATUSDESCRIPTION>Success</STATUSDESCRIPTION> 
      </item> 
     </STATUS> 
     </n0:ZFIFM_VIRTUAL_ACCOUNTResponse> 
    </soap-env:Body> 
</soap-env:Envelope> 

問題是我怎麼能我使用這個方法來調用soapCLient而得到的BILLDETAILS陣列:

$x = $client->ZFIFM_VIRTUAL_ACCOUNT(array("BILLKEY1"=>"8871711140100014")); 

我已經與count($x->BILlDETAILS)嘗試,但它只有返回值1,而當我耳邊迴響:echo $x->BILLDETAILS[0]; 它打印空白..

請我需要一個建議.. 感謝..

回答

0

試試這樣說:

foreach ($x->BILLDETAILS->item as $key => $item) { 
    var_dump($item); 
} 
+0

它不會工作,返回空(空白)..感謝反正... – Tejo

+0

提供請'的var_dump( $ x-> BILLDETAILS)'以免猜 – buildok

+0

return:object(stdClass)#3(0){} – Tejo