Using Regex to get data from a large response

My question:
I have a large response that is in XML and I am wanting to do regex to get the event/Selection ids from it to save to an array ( or the best way to do this)

Details (like screenshots):

How I found the problem:
Trying to get data for my next request

I’ve already tried:
I have tried different version of below

//const responseText = pm.response.text();
//const matches = responseText.match(/event id= (.*?)/);
//const sessionId = matches[1];
//const sessionId = matches;

//const vartest = pm.expect(response.body).to.match(/event id=(.*?)/);

//const vartest = pm.expect(response.body).to.match(/event id=/);

const vartest = pm.expect(response.text()).to.match(/event id=/);

Hello @fenwickr ,
An alternative solution could be to convert the return to Json and then use the Javascript filter to get the ids.

I’ll put it here below with converting XML into Json:

const responseJson = xml2Json(responseBody);

let responseNoEnvelope = responseJson['soap:Envelope'];

And then you use the filter in responseNoEnvelope to get the ids.

I hope this has helped and any questions I am available :slight_smile:

1 Like