Forum Discussion
I suspect, you are iterating it in a wrong node position. Instead of this -
for( item in holder.getNodeValues( "//document-description" ))
you should move up one level and should iterate as shown below,
for( item in holder.getNodeValues( "//available-document" ))
Again, for the change in number of occurrences of <document-group> , the getNodeValues() method is capable of returning a String array, where you can compute for to get comma separated values.
Thanks,
Kondasamy
- juraterfan9 years agoNew Contributor
Hello Kondasamy,
Thank you for your response, I get the idea that I can use holder.getNodeValues("//document-group") to retrieve all the document-group in the XML, but how would i go about retrieve just the <document-group> that are within the <available-document> ? the reason is that I will have multiple <available-document> and the number of time it appears in the response will change, now the idea is to iterate through all the <available-document> in the XML and in each <available document> i would like to iterate through the XML and retrieve the <document-group> that are in it. I wasnt having any solution on how would I go about nested iteration.
Thank you
You can check XMLSlurper,
http://docs.groovy-lang.org/latest/html/api/groovy/util/XmlSlurper.html
Thanks