title: Counting response nodes in soapUI with groovy
body: <p>I am trying to count response nodes and then do something over the amount of nodes.
  I've tried it in the following groovy script but the count remains "0":</p>
  
  <pre><code>def collection = ["1","2","3","4"]
  
  // get num repetitions of &lt;SubsPlanDto&gt; with Xpath count
  def numElements = context.expand( '${QuerySubsPlanList - Request 1#Response#//count(*:QuerySubsPlanListResponse[1]/SubsPlanDtoList[1]/SubsPlanDto)}')
  def collection2 = [];
  // iterate and add the values to a collection
  for ( i in 1..numElements.toInteger()) {
      collection2.add(context.expand( '${QuerySubsPlanList - Request 1#Response#//*:QuerySubsPlanListResponse[1]/SubsPlanDtoList[1]/SubsPlanDto['+ i + ']/SubsPlanCode[1]}'))
  }
  
  // get the matches and differences
  def matches = collection.intersect(collection2)
  def fails = collection.plus(collection2)
  fails.removeAll(matches)
  
  log.info matches
  log.info fails
  </code></pre>
  
  <p>The structure of the response is as follows</p>
  
  <pre><code>xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
     &lt;soapenv:Body&gt;
        &lt;ns:QuerySubsPlanListResponse xmlns:ns="http://com.ztesoft.zsmart/xsd"&gt;
           &lt;SubsPlanDtoList&gt;
              &lt;SubsPlanDto&gt;
                 &lt;SubsPlanCode&gt;TEST1&lt;/SubsPlanCode&gt;
                 &lt;ServType&gt;M&lt;/ServType&gt;
                 &lt;CustTypeList&gt;B2B&lt;/CustTypeList&gt;
                 &lt;Price&gt;0.0000&lt;/Price&gt;
              &lt;/SubsPlanDto&gt;
              &lt;SubsPlanDto&gt;
                 &lt;SubsPlanCode&gt;TEST2 &lt;/SubsPlanCode&gt;
                 &lt;ServType&gt;M&lt;/ServType&gt;
                 &lt;CustTypeList&gt;B2C|B2B&lt;/CustTypeList&gt;
                 &lt;Price&gt;0.0000&lt;/Price&gt;
              &lt;/SubsPlanDto&gt; 
  </code></pre>
  
  <p>Can anyone tell me how to count the nodes correctly? 
  Thanks</p>