cancel
Showing results for 
Search instead for 
Did you mean: 

How to read parent and child nodes in groovy?

Occasional Contributor

How to read parent and child nodes in groovy?

Hello,

I have a response like this


 
 


 
 


Can some one please help me giving me leads to code the groovy assertion to get the child elements based on its parent?

Example, I need value of name under the first parent node that is ax21:stageset.

In my current script i am doing

def holder = groovyUtils.getXmlHolder( messageExchange.responseContent )

def name = holder.getNodeValue("//ax21:name")

this gets me the last one it reads. Is there a way to specify the parent.name like stageset.name or fabstageset.name?

Thanks in advance!
- Shashi
2 REPLIES 2
Super Contributor

Re: How to read parent and child nodes in groovy?

Hi Shashi,

please try the following instead;

def name = holder.getNodeValue("//ax21:stageset/ax21:name")

or

def name = holder.getNodeValue("//ax21:fabstageset/ax21:name")

regards!

/Ole
eviware.com
Occasional Contributor

Re: How to read parent and child nodes in groovy?

Thanks for the reply. It is working perfectly as expected.
- Shashi