Jseban
8 years agoOccasional Contributor
Looping through JDBC response xml
I am trying to write the results of a JDBC query result to an excel sheet. In my code I am looping through each element using a for loop. But when I use the looping variable(i) inside the context.expand variable, it is not giving me any results.
Ex. context.expand( '${JDBCRequest#ResponseAsXml#//Row[i]/FirstColumn}' )
If I change this to Row[1], I am getting the expected result. Could someone please help me to resolve this issue?
Your variable should be added to the string separately like
context.expand( '${JDBC Request#ResponseAsXml#//Row[' + i + ']/FirstColumn}' )
FYI
http://stackoverflow.com/questions/27271509/how-to-get-attributes-in-groovy-via-xpath