Forum Discussion

AnkurB's avatar
AnkurB
New Contributor
10 years ago

How to fetch XML node in SOAP Ui through groovy?

Hi,

I am working on a project to automate the back end services. I am stuck on couple of points:

1. How to fetch a node from the XML response generated with one of the request in test suite? I want to fetch the value dynamically. I want to store that value in a variable and use it as per requirement to compare and pass on in some other request.
2. I need to connect to a particular column in database which contains the XML logs. Then fetch the numeric amount value from the XML and compare with the XML response I received through SOAP UI

any help or clue in this would be really appreciated.

3 Replies

  • PaulDonny's avatar
    PaulDonny
    Regular Contributor
    The groovy XmlSlurper might be your best option.



    As for comparing Xml, if it's supposed to be identical than I would just go a regex style comparison. If there will be differences, I would loop through each of the values and compare. If there is supposed to be a lot of differences, I would compare the values that you are attempting to validate.
  • AnkurB's avatar
    AnkurB
    New Contributor
    Thanks PaulM.

    I will try this. Since I am new to Groovy, can the objective be achieved by writing a piece of code to fetch the dynamic XML from the database and use in SOAP UI?