Forum Discussion

AnandKiran's avatar
AnandKiran
Frequent Contributor
16 years ago

Want to collect the values from the nodes

Hi Ole,
          I have a requirement where i need to collect all the values from the nodes .. I have pasted the Response also , using groovy i want to store the values in an Array .




 
     
       
           
             

           

            4f90684f-4d39-490a-abec-4105c4bb6489
           
             
           

            0.2691260000000000
       

       
           
              True
             
                  Iain Banks
                  New
                  Ship
                  Amazon
                  Small
                  -SubmissionDate
                  Books


I  was using the below script for collect the values but it didnt work ..

import com.eviware.soapui.support.*;
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder ("Test Request#Response")

Output= holder.getNodeValues("//Author")

UISupport.showInfoMessage("author is ${Output}")

can you give me a solution for this issue .

Thanks with regards
Anand Kiran

3 Replies

  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Can anyone provide me a solution for this problem


    Thanks
    With Regards
    Anand Kiran
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Anand,


    The reason your snippet wasn't able to access the node from SOAP response is because you didn't register the default namespace for your particular SOAP response message.

    Try this:

    def  groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def  holder = groovyUtils.getXmlHolder ("Test Request#Response")

    holder.namespaces["aws"] = "http://webservices.amazon.com/AWSECommerceService/2007-02-22"
    output = holder.getNodeValues("//aws:Author")
    UISupport.showInfoMessage("author is ${output}")


    I hope this will work out for you.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi

      Thanks alot for your reply , it was very helpful

    Cheers!!!