sanjeevkumar7
14 years agoOccasional Contributor
Count number of child nodes
How to find the number of child nodes in a xml node.
For example : I can find the number of child nodes using xmlslurper() the below way.
I'm able to get the value using "holder" (groovyutils.getxmlholder) with the below code.
Could you please let me know how to get the number of child nodes using the holder?
Thanks!
Sanjeev
For example : I can find the number of child nodes using xmlslurper() the below way.
def path = new XmlSlurper().parse(new File('C://SoapUI//ResponseXML/Response.xml'))
NumberOfPositions = path.Body.GetPositionsAggregateResponse.GetPositionsAggregateResult.AccountPositions.Securities.Positions.children().size()
I'm able to get the value using "holder" (groovyutils.getxmlholder) with the below code.
positionid1 = holder.getNodeValue("//ns1:GetPositionsAggregateResponse[1]/ns1:GetPositionsAggregateResult[1]/a:AccountPositions[1]/a:Securities[1]/a:Positions[1]/a:PositionSummary[1]/a:Legs[1]/a:PositionAggregate[1]/a:PositionID[1]")
log.info ("$positionid1")
Could you please let me know how to get the number of child nodes using the holder?
Thanks!
Sanjeev