Forum Discussion

Pragmatics__Inc's avatar
Pragmatics__Inc
Occasional Contributor
14 years ago

Accessing Child Nodes with getXmlHolder

I have to verify the child nodes of a list of nodes in an XML response. I'm doing the following:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( messageExchange.responseContentAsXml )
holder.namespaces["plan"] = "SOMEURL/plan"
ii = 1
for ( item in holder.getNodeValues("//rr:GetAllUlnResponse[1]/plan:ULN") ){
if ( holder.getNodeValue("//rr:GetAllUlnResponse/plan:ULN[$ii]/RDL[1]") != "374" ) {
assert false
}
else if ( holder.getNodeValue("//rr:GetAllUlnResponse/plan:ULN[$ii]/STIC[1]") != "N" ) {
assert false
}
ii = ii + 1
}
assert true


This works, but is rather slow and seems 'ungroovy'. I was wondering if there is a way to access the item I am actually iterating on to get at it's children, like

pseudocode: if (item.RDL[1].value != "374") {


or if I can avoid creating the item altogether to save memory and perhaps speed up the query.

Is there a way to do either to avoid having to count the items or is this the best way to do this?
No RepliesBe the first to reply