Hello
I try to generate XML-file as output report by script.
I write some code:
function writeXml(xmlOutput, xmlParent, oItem, sElement) {
var xmlItem = xmlOutput.addElement(xmlParent, sElement);
xmlItem.setAttribute("Attr1", oItem.Att1);
xmlItem.setAttribute("Attr2", oItem.Att2);
return xmlItem;
}
function main() {
var aItem = new Array();
aItem.push({Att1:"x1", Att2:"y1"});
aItem.push({Att1:"x11", Att2:"y11"});
aItem.push({Att1:"x12", Att2:"y12"});
var xmlOutput = Context.createXMLOutputObject(Context.getSelectedFile(), "Root");
var xmlItem1 = writeXml(xmlOutput, xmlOutput.getRootElement(), aItem[0], "Item1");
var xmlItem11 = writeXml(xmlOutput, xmlItem1, aItem[1], "Item11");
var xmlItem12 = writeXml(xmlOutput, xmlItem1, aItem[2], "Item12");
xmlOutput.WriteReport();
}
main();
After launching this script I get XML-file:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Item1 Attr2="y1" Attr1="x1">
<Item11 Attr2="y11" Attr1="x11"/>
<Item12 Attr2="y12" Attr1="x12"/>
</Item1>
</Root>
Tell me please, how can I generate XML-file with structure like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aris="http://test.ru/portal/aris">
<soapenv:Header/>
<soapenv:Body>
<aris:arisUrlRequest>
<ATTR1>?</ATTR1>
<ATTR2>?</ATTR2>
</aris:arisUrlRequest>
</soapenv:Body>
</soapenv:Envelope>