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请求的另一端...有什么帮助?