def request = '''<xml>
<node>
<val1>pqr</val1>
<val2>abc</val2>
</node>
<node>
<val1>xyz</val1>
<val2>lmn</val2>
</node>
</xml>'''
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = new com.eviware.soapui.support.XmlHolder( request )
// loop item nodes in response message
//get All occurance of node/val1
log.info "--------First For loop------------"
for( item in holder.getNodeValues( "//node/val1" ))
log.info "Node : [$item]"
OUTPUT
Sun Nov 23 19:51:36 IST 2014:INFO:--------First For loop------------
Sun Nov 23 19:51:36 IST 2014:INFO:Node : [pqr]
Sun Nov 23 19:51:36 IST 2014:INFO:Node : [xyz]
Sun Nov 23 19:51:36 IST 2014:INFO:--------Second For loop------------
Sun Nov 23 19:51:36 IST 2014:INFO:Node : [pqr]
<node>
<val1>pqr</val1>
<val2>abc</val2>
</node>
<node>
<val1>xyz</val1>
<val2>lmn</val2>
</node>
</xml>'''
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = new com.eviware.soapui.support.XmlHolder( request )
// loop item nodes in response message
//get All occurance of node/val1
log.info "--------First For loop------------"
for( item in holder.getNodeValues( "//node/val1" ))
log.info "Node : [$item]"
OUTPUT
Sun Nov 23 19:51:36 IST 2014:INFO:--------First For loop------------
Sun Nov 23 19:51:36 IST 2014:INFO:Node : [pqr]
Sun Nov 23 19:51:36 IST 2014:INFO:Node : [xyz]
Sun Nov 23 19:51:36 IST 2014:INFO:--------Second For loop------------
Sun Nov 23 19:51:36 IST 2014:INFO:Node : [pqr]
No comments:
Post a Comment