Xml2js tag name has a hyphen in name

xml2js is also available in the Postman sandbox and gives you a lot more control over the output.

For example…

let respBodyXML = pm.response.text();

let parseString = require('xml2js').parseString;

parseString(respBodyXML, {
    ignoreAttrs: true, 
    explicitArray: false,
}, function (err, result) {
    console.log(result);
});

This produces output like the following. It removes the $ signs, and looks more like a proper JSON object.

image

It depends on how complex your XML is, but have a look here (scroll to the bottom) for all of the formatting options.

xml2js - npm (npmjs.com)

Have a look here for another topic that shows some of the formatting options in action.

How to retrieve the names of xml tags - :person_raising_hand: Help - Postman Community

2 Likes