Nikolaj
12 years agoOccasional Contributor
How get multiple value from difficult response
Hi All,
I have a little problem. My response is:
I need to get the values of Derivative Name lines only. I use groovy script:
Groovy script result is: SL-50 TE, AR SL-50, Ariston, SL-50 TE-HA, AR SL-50, Ariston
But I need that result should be: SL-50 TE, SL-50 TE-HA only
Please advice how I do it better.
Any suggestion is appreciated.
Thanks in advance.
I have a little problem. My response is:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetDerResponse xmlns="http://www.test.com/Services">
<GetDerResult xmlns:a="http://schemas.data.org/2004/07/Data" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Derivative>
<Code xmlns="http://www.test.com/Data">SL501</Code>
<Id xmlns="http://www.test.com/Data">90941</Id>
<Name xmlns="http://www.test.com/Data">SL-50 TE</Name>
<a:DeliveryCharge i:nil="true"/>
<a:LongName>SL-50 TE</a:LongName>
<a:Model>
<Code xmlns="http://www.test.com/Data">AS2</Code>
<Id xmlns="http://www.test.com/Data">0</Id>
<Name xmlns="http://www.test.com/Data">AR SL-50</Name>
<a:LongName>AR SL-50</a:LongName>
<a:Manufacturer>
<Code xmlns="http://www.test.com/Data"/>
<Id xmlns="http://www.test.com/Data">0</Id>
<Name xmlns="http://www.test.com/Data">Ariston</Name>
</a:Manufacturer>
</a:Model>
</a:Derivative>
<a:Derivative>
<Code xmlns="http://www.test.com/Data">SL502</Code>
<Id xmlns="http://www.test.com/Data">90942</Id>
<Name xmlns="http://www.test.com/Data">SL-50 TE-HA</Name>
<a:DeliveryCharge i:nil="true"/>
<a:LongName>SL-50 TE-HA</a:LongName>
<a:Model>
<Code xmlns="http://www.test.com/Data">AS2</Code>
<Id xmlns="http://www.test.com/Data">0</Id>
<Name xmlns="http://www.test.com/Data">AR SL-50</Name>
<a:LongName>AR SL-50</a:LongName>
<a:Manufacturer>
<Code xmlns="http://www.test.com/Data"/>
<Id xmlns="http://www.test.com/Data">0</Id>
<Name xmlns="http://www.test.com/Data">Ariston</Name>
</a:Manufacturer>
</a:Model>
</a:Derivative>
I need to get the values of Derivative Name lines only. I use groovy script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder("MyTestStepName#Response")
for (h in holder["//*:Name"]){
log.info(h)
}
Groovy script result is: SL-50 TE, AR SL-50, Ariston, SL-50 TE-HA, AR SL-50, Ariston
But I need that result should be: SL-50 TE, SL-50 TE-HA only
Please advice how I do it better.
Any suggestion is appreciated.
Thanks in advance.