Forum Discussion

borodinandrey's avatar
15 years ago

How to select single value from large response string?

Hello,
I'am getting service response as a single Response string with a bunch of parameters that looks like:

<Response><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PaymentWriteResult>
<EventId>5</EventId>
<Operations>
<ResultData/>
</Operations>
</WriteResult>]]></Response>


How can I select only EventId number from all of this (for transferring it to next step)? Xpath expression is not work for me as it able to declare only whole response string.

Thank you!

1 Reply

  • Hi,

    To extract the particular value, you'll need to use regex.
    The value can be validated using script assertion.
    Write a simple code in groovy in that script assertion.
    Here is a sample:

    def response = <using get data, take the response string here>
    def eventId = response.split("EventId>")[1].replaceAll("<","").replaceAll("////","")

    //it will return the value of eventId
    // now assert with the desired value

    assert eventId == <desired value>

    Hope it helps.

    Regards,
    -