Forum Discussion
aaronpliu
8 years agoFrequent Contributor
Hi shubhimu ,
Your GPath should looks like below then it's able to work
"Body"."abc"."deviceUnits"."devicePorts"."serviceEntities"
if defined variable to save, then using
// assumed that variable: a, b, c "$a"."$b"."$c"
shubhimu
8 years agoContributor
Yeah i know this and its working for me ..
But i dont want to break it in to n number of variables.
I want one variable should suffice the purpose...
Please let me know if we can do this way.
Thanks,
Himanshu
- shubhimu8 years agoContributor
I got the solution.
def xml=getNodes(resource,xpaths)
log.info xml.did.size()
def getNodes(doc,path){
def nodes = doc;
path.split("\\.").each {
log.info "node size for "+ "${it}" +" is "+nodes.size()
if(nodes.size() == 1){
nodes = nodes."${it}";
}else{
nodes = nodes[0]."${it}"
}
log.info "${it}"
}
log.info "Nodes is "+nodes
return nodes
}