Forum Discussion

sanjeevkumar7's avatar
sanjeevkumar7
Occasional Contributor
14 years ago

[Resolved] Using XmlSlurper in soapUI

Hi - I have the below groovy script which I run in groovyconsole and it runs just fine. I'm finding the number of child nodes for a particular node in my xml response and printing out required values for each child node.

def path = new XmlSlurper().parse(new File('C://SoapUI//ResponseXML/Response.xml'))
NumberOfPositions = path.Body.GetPositionsAggregateResponse.GetPositionsAggregateResult.AccountPositions.Securities.Positions.children().size()
for(def i=0; i<NumberOfPositions; i++){
println i

println path.Body.GetPositionsAggregateResponse.GetPositionsAggregateResult.AccountPositions.Securities.Positions.PositionSummary[i].Legs[0].PositionAggregate[0].PositionID[0].text()
println path.Body.GetPositionsAggregateResponse.GetPositionsAggregateResult.AccountPositions.Securities.Positions.PositionSummary[i].Legs[0].PositionAggregate[0].AccountID[0].text()

}


I want to perform the same task in soapUI, but couldn't get it working using groovyutils as mentioned here : http://www.soapui.org/Scripting-Propert ... ricks.html

1) How do I parse the xml response from my request to xmlSlurper?
def path = new XmlSlurper().parse (?)

2) Would I be able to use the same code above in soapUI too?



Any help is appreciated. Thanks!
No RepliesBe the first to reply