Parse XML -> JSON, then pass full contents to webhook


Beginner here. I need to connect one app to my CRM and pull all the data possible so I can pass it to a webhook (via Zapier). However, the results are XML, but the webhook needs them in JSON.

I have scoured here and StackOverflow and found a lot of OK code, but none seems to do what I need to do.

Here’s a sample of the XML:

<?xml version="1.0" encoding="utf-8"?>
    <Link rel="link">
            <Name>Event Name</Name>
            <LocationName>New York</LocationName>
            <Link rel="self" type="application/xml" href="link"/>
            <Link rel="self" type="application/xml" href="link"/>

And here’s what I can get using xml2json:

Any help on:

  • Converting this XML to JSON
  • Passing all of it to a POST request also in Postman

Would be much appreciated.


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

For example…

let respBodyXML = pm.response.json().data;

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

parseString(respBodyXML, {
    ignoreAttrs: true, 
    explicitArray: false,
}, function (err, result) {


Have a look here (scroll to the bottom for all of the formatting options).

xml2js - npm (

With regards to your webhook, you need to provide an example JSON structure that the webhook will accept.

You have 67 links in your screenshot, so I suspect you will need to loop through the JSON produced by the above code, and retrieve the details you need to create a new JSON object in the correct structure for your webhook.

If you need help with this, please provide details on what the webhook will accept and an XML example with more than one link.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.