# How to parse xml within CDATA inside XML host response?

**URL:** <https://community.postman.com/t/how-to-parse-xml-within-cdata-inside-xml-host-response/16085>\
**Category:** Help Hub\
**Tags:** xml-parsing, variables, json, xml-response, tests\
**Created:** [September 21, 2020, 3:27pm UTC](https://community.postman.com/t/how-to-parse-xml-within-cdata-inside-xml-host-response/16085 "2020-09-21T15:27:41Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![kevin.swiber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevin.swiber/32/3820_2.png) [@kevin.swiber](https://community.postman.com/u/kevin.swiber)\
**Post date:** [September 22, 2020, 4:43pm UTC](https://community.postman.com/t/how-to-parse-xml-within-cdata-inside-xml-host-response/16085/4 "2020-09-22T16:43:43Z")

</div>

Hi @alberto.bura,

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

```auto
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](https://community.postman.com/t/xml-response-escape-characters/14450/2)

Best,

Kevin

---

_[View the full topic](https://community.postman.com/t/how-to-parse-xml-within-cdata-inside-xml-host-response/16085)._
