-1

I have a very simple little iterator here

maps.each
{

    d = resXml.ResultSet.Row.it.text()
    log.info d

}

it is obviously the element name i'm trying to access the info in, and if i say log.info it instead of log.info d i do get the correct names (A new line B new line C), but doing like i just showed you results in nothing - so i went and checked one of the it returns manually (d = resXml.ResultSet.Row.A.text()) and i did get the result i was looking for.

I'm at a total loss, i'm not even sure how to search for this question - i'm using soapUI Open Source and maps is also from an xmlSlurper object but its format is fine: [A,B,C]

imp
  • 435
  • 6
  • 20

2 Answers2

0

Your it is being interpreted as a property/node named "it". XML."$it".andSoOn (using a g string) should work per Using a variable to extract value of property of an element in groovy using xmlSlurper

This assumes it is a string.

Community
  • 1
  • 1
Matt Rkiouak
  • 141
  • 7
  • uhm, my way works. Does exactly what i need it to and the way above is just a complicated way of iterating through multiple trees, i have one tree – imp Aug 05 '15 at 18:58
  • Your answer is identical to what I've described above, but my answer explains why your question does not work as expected. – Matt Rkiouak Aug 05 '15 at 19:04
  • Thanks Matt, teaches me for being up for 20 hours straight and too much coffee. You are absolutely correct – imp Aug 06 '15 at 08:50
-1

By using:

d = resXml.ResultSet.Row."${it}".text()

or:

d = resXml.ResultSet.Row./${it}/.text()
imp
  • 435
  • 6
  • 20