Forum Discussion
aaronpliu
Frequent 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
7 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
- shubhimu7 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
}
Related Content
- 10 years ago
- 7 years ago
- 10 years ago
Recent Discussions
- 18 hours ago
- 17 days ago