簡體   English   中英

使用SOAP PHP創建XML消息

[英]Creating XML messages with SOAP PHP

大家好。 我正在嘗試使用PHP SOAPClient創建類似的XML標簽。 我了解如何創建所需的xml。 但是,到了我需要創建具有相同標簽名稱但屬性不同的XML標簽的地步:

<Rates> 
    <Rate EffectiveDate="2011-12-15"> <Total AmountAfterTax="155" /> </Rate> 
    <Rate EffectiveDate="2011-12-16"> <Total AmountAfterTax="155" /> </Rate>
    <Rate EffectiveDate="2011-12-17"> <Total AmountAfterTax="155" /> </Rate>  
</Rates>

我目前使用foreach循環創建此行:

$request->Reservation['Rates'] = "";

foreach($Array['Rates'] as $Value)
{
    $request->Reservation['Rates']['Rate'] 
        = array("EffectiveDate" => $value['Date']);
    $request->Reservation['Rates']['Rate']['Total'] 
        = array("AmountAfterTax" => $value['Price']);
}

您是否嘗試過像這樣設定一系列價格?

$request->Reservation['Rates'] = "";
$Length = count($Array['Rates']);

for ($i = 0; $i < $Length; $i++)
{
    $request->Reservation['Rates'][$i]['Rate'] 
        = array("EffectiveDate" => $Array['Rates']['Date']);
    $request->Reservation['Rates'][$i]['Rate']['Total'] 
        = array("AmountAfterTax" => $Array['Rates']['Price']);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM