Bichoo
13 years agoNew Contributor
How to remove nodes on some condition
HI
I have been trying to remove the nodes which have '?'(question mark) as value , from my soapui request. I am using xmlHolder() for this ,following is the groovy code
for(TS in project.testSuiteList) {
for(TC in TS.testCaseList) {
for(TStp in TC.testStepList) {
if(TStp instanceof WsdlTestRequestStep){
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def req=TStp.getPropertyValue("Request")
def request = context.expand(req)
def holder = groovyUtils.getXmlHolder( TStp.testRequest.requestContent )
use (groovy.xml.dom.DOMCategory) {
for( node1 in holder.getDomNodes( "//pay:orderData" )) {
node1.children().each { child ->
if(child.text()=="?"){
node1.parentNode.removeChild( node1 )
}
}
}
}
}
}
}
}
but this block of code is not working for me ..
. I dont want to use xmlparser or xmlslurper for this . I am very badly struck in this .. Any help would be grtly appropriated
Regrads
Bichoo
I have been trying to remove the nodes which have '?'(question mark) as value , from my soapui request. I am using xmlHolder() for this ,following is the groovy code
for(TS in project.testSuiteList) {
for(TC in TS.testCaseList) {
for(TStp in TC.testStepList) {
if(TStp instanceof WsdlTestRequestStep){
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def req=TStp.getPropertyValue("Request")
def request = context.expand(req)
def holder = groovyUtils.getXmlHolder( TStp.testRequest.requestContent )
use (groovy.xml.dom.DOMCategory) {
for( node1 in holder.getDomNodes( "//pay:orderData" )) {
node1.children().each { child ->
if(child.text()=="?"){
node1.parentNode.removeChild( node1 )
}
}
}
}
}
}
}
}
but this block of code is not working for me ..

Regrads
Bichoo