开发者

Creating XML messages with SOAP PHP

开发者 https://www.devze.com 2023-02-27 04:25 出处:网络
Hey all. I am trying to create similar XML tags with PHP SOAPClient. I understand how to create the xml i need. However, it has come to a point where I need to create XML tags that have the same tag n

Hey all. I am trying to create similar XML tags with PHP SOAPClient. I understand how to create the xml i need. However, it has come to a point where I need to create XML tags that have the same tag names but different attributes:

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

I currently use a foreach loop to create this line:

$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']);
}


Have you tried making an array of rates, like so?

$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']);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消