Forum Discussion

slg12345's avatar
slg12345
Occasional Contributor
14 years ago

Unable to substitute variable in context.expand....

def cdUser= context.expand( '${Copy of JDBC Request - check User table#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/User[1]}' ) as int
log.info cdUser-----> works fine

//There are 4 rows in the response

def int cdQty=4

for (int ctr=1;ctr<=cdQty;ctr++)
{
cdUser= context.expand( '${Copy of JDBC Request - check User2 table#ResponseAsXml#//Results[1]/ResultSet[1]/Row[ctr]/User[1]}' )
}

===>cdUser is NULL, as 'ctr' does not substitute numbers instead.

If I replace ctr in context.expand with numbers, it works good.
Please let me know asap, how variable value can be substituted in context.expand
  • slg12345's avatar
    slg12345
    Occasional Contributor
    It works as follows
    ==>
    cdUser= context.expand( '${Copy of JDBC Request - check User2 table#ResponseAsXml#//Results[1]/ResultSet[1]/Row['+ctr+']/User[1]}' )