0
我正在使用一些遺留代碼,並且必須更新使用E4X構建的SOAP請求。我有一組數據需要循環並構建重複的XML段並將它們插入到SOAP請求中。我的僞例如...創建循環中E4X聲明
var myData = ['apples','oranges','pears','grapes'];
var myFruit;
for(var i=0; i<myData.length; i++){
myFruit += <fruit>{myData[i]}</fruit>;
}
var request = <soapenv:Envelope>
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<MyFruitList>
{myFruit}
</MYFruitList>
</soapenv:Body>
</soapenv:Envelope>;
這工作EXCEPT所有{} myFruit標籤的出現已經越獄..它看起來像這樣..
<soapenv:Envelope>
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<MyFruitList>
<fruit>apples</fruit>
<fruit>oranges</fruit>
<fruit>pears</fruit>
<fruit>grapes</fruit>
</MYFruitList>
</soapenv:Body>
</soapenv:Envelope>;
..這失敗,則上我的SOAP請求的另一端...有什麼幫助?