pkunst
11 years agoContributor
[Resolved] Counting nodes of response
Hi together
I have another problem with SaopUI.
I have such a structure as response
I am trying to count the nodes of a response. May first idea was to put the node in a string and then count the substring “ElementOfList” and divide it with 2. It works nearly fine except that the .count method count not enough. I had 32 child nodes of “List” but it only counts 31.
Regards
Patrick
I have another problem with SaopUI.
I have such a structure as response
<Envelope>
<Header>
</Header>
<Body>
<Response>
<Result>
<List>
<ElementOfList>
</ElementOfList>
<ElementOfList>
</ElementOfList>
<ElementOfList>
</ElementOfList>
<ElementOfList>
</ElementOfList>
</List>
<Result>
</Response>
</Body>
</Envelope>
I am trying to count the nodes of a response. May first idea was to put the node in a string and then count the substring “ElementOfList” and divide it with 2. It works nearly fine except that the .count method count not enough. I had 32 child nodes of “List” but it only counts 31.
String list = testRunner.testCase.getPropertyValue( "purchaseOrderItemDTOList")
int i= list.count("PurchaseOrderItemDTO")
testRunner.testCase.setPropertyValue( "counter",i.toString())
So I search on your homepage and found that: http://www.soapui.org/Scripting-Properties/tips-a-tricks.html#3-2-count-nodes
That does not work at all. The result is 0 and I don’t know why. Hope you can help me.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder("GetListOfPurchaseOrderItems#Response")
log.info holder
def i = holder["count(//Envelope/Body/Response/Result//List/ChildElement)"]
Regards
Patrick