简体   繁体   English

使用SOAP PHP创建XML消息

[英]Creating XML messages with SOAP PHP

Hey all. 大家好。 I am trying to create similar XML tags with PHP SOAPClient. 我正在尝试使用PHP SOAPClient创建类似的XML标签。 I understand how to create the xml i need. 我了解如何创建所需的xml。 However, it has come to a point where I need to create XML tags that have the same tag names but different attributes: 但是,到了我需要创建具有相同标签名称但属性不同的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>

I currently use a foreach loop to create this line: 我目前使用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']);
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM