How to parse xml within CDATA inside XML host response?

Hi @alberto.bura,

I would use the xml2js module as xml2Json is included as part of the legacy sandbox API. Try something like this:

const xml2js = require('xml2js');
xml2js.parseString(pm.response.text(), (err, result) => {
    if (err) {
        console.error(err);
        return;
    }

    const body = result.VASMessage.Body[0].VASDataString[0];
    
    xml2js.parseString(body, (err, result) => {
        if (err) {
            console.error(err);
            return;
        }
        console.log(result);
    })
});

Related: XML response escape characters

Best,

Kevin

1 Like