here's the solution: extract what you need...
/*
[Script Name ] DLC Parsing
[Purpose ] Parses service codes from an excel test data sheet and insert relating nodes into XML SOAP-request.
[Created ] 2009-09-22
[Last Modified] -
[Author ] Sven Zaugg
[Company ] Zühlke Engineering AG
*/
def stepName = "GenerateLabel";
// read current SOAP request XML file
def request = testRunner.testCase.getTestStepByName(stepName);
def property = request.getProperty("request");
def rootNode = new groovy.util.XmlParser(false,false).parseText(property.value);
// delete previous service codes
def tmpAttributeList = [];
def attributesNodes = rootNode["soapenv:Body"]["typ:$stepName"]["typ:Envelope"]["typ:Data"]["typ:Provider"]["typ:Sending"]["typ:Item"]["typ:Attributes"][0].children();
for (attribute in attributesNodes) {
if (attribute.name() != "typ:ATT_PRZL") {
// [c1]: save temporary attribute nodes for sticking to sequence restriction defined in relating XSD schema
tmpAttributeList.add(attribute);
log.info attribute;
}
}
// see comment [c1]
attributesNodes.clear();
// read service codes values from excel data sheet
def dlcField = context.expand( '${ExcelSheet#ATT_PRZL}' )
def dlcCodes = dlcField.split(',')
// update SOAP request XML file with service codes
def attributesNode = rootNode["soapenv:Body"]["typ:$stepName"]["typ:Envelope"]["typ:Data"]["typ:Provider"]["typ:Sending"]["typ:Item"]["typ:Attributes"][0];
for (code in dlcCodes) {
attributesNode.appendNode("typ:ATT_PRZL", code);
}
// back up old attributes data, see comment [c1]
for (attribute in tmpAttributeList) {
attributesNode.append(attribute);
}
// save changes in SOAP request XML file before start sending it
def writer = new java.io.StringWriter();
def printer = new groovy.util.XmlNodePrinter( new PrintWriter( writer ));
printer.print( rootNode );
def xmlString = com.eviware.soapui.support.xml.XmlUtils.prettyPrintXml(writer.toString())
property.setValue( xmlString )