Facing problem parsing XML
Whomsoever it may concern
Please help in solving this issue.
I am able to get the response but not able to get node values.
Groovy Script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def requsetHolder = groovyUtils.getXmlHolder( "Define - Request#Request")
def responseContent = testRunner.testCase.getTestStepByName("MockResponseDefine").getPropertyValue("response")
def responseHolder = groovyUtils.getXmlHolder("Define - Request#Response")
log.info(responseHolder.getPrettyXml())
log.info(responseHolder["count(//DefineResponse/DefineResult/Word)"])
// loop item nodes in response message
for( item in responseHolder.getNodeValues( "//DefineResponse/DefineResult/Word" ))
log.info "\nItem : [$item]"
Output:
Wed Mar 21 15:46:55 IST 2018:INFO:<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<DefineResponse xmlns="http://services.aonaware.com/webservices/">
<DefineResult>
<Word>Hello</Word>
<Definitions>
<Definition>
<Word>Hello</Word>
<Dictionary>
<Id>gcide</Id>
<Name>The Collaborative International Dictionary of English v.0.44</Name>
</Dictionary>
<WordDefinition>Hello \Hel*lo"\, interj. & n.
An exclamation used as a greeting, to call attention, as an
exclamation of surprise, or to encourage one. This variant of
{Halloo} and {Holloo} has become the dominant form. In the
United States, it is the most common greeting used in
answering a telephone.
[1913 Webster +PJC]</WordDefinition>
</Definition>
<Definition>
<Word>Hello</Word>
<Dictionary>
<Id>wn</Id>
<Name>WordNet (r) 2.0</Name>
</Dictionary>
<WordDefinition>hello
n : an expression of greeting; "every morning they exchanged
polite hellos" [syn: {hullo}, {hi}, {howdy}, {how-do-you-do}]</WordDefinition>
</Definition>
</Definitions>
</DefineResult>
</DefineResponse>
</soap:Body>
</soap:Envelope>
Wed Mar 21 15:46:55 IST 2018:INFO:0