Ask a Question

Looping through JDBC response xml

SOLVED
Jseban
Occasional 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?

1 ACCEPTED SOLUTION

Accepted Solutions
PaulMS
Super Contributor

Re: Looping through JDBC response xml

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

View solution in original post

4 REPLIES 4
nmrao
Community Hero

Re: Looping through JDBC response xml

Please show raw response? what is issue if you get expected result?


Regards,
Rao.
Jseban
Occasional Contributor

Re: Looping through JDBC response xml

I get the result only if I use Rows[1]. But its not giving me result if I use like Rows[i]. I want to use context.expand( '${JDBCRequest#ResponseAsXml#//Row[i]/FirstColumn}' ) inside a for loop to get all the rows from the query result.

Thank you
PaulMS
Super Contributor

Re: Looping through JDBC response xml

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

View solution in original post

Jseban
Occasional Contributor

Re: Looping through JDBC response xml

That fixed it. Thanks a lot. 

cancel
Showing results for 
Search instead for 
Did you mean: