# Converting from XML to JSON

**URL:** <https://community.postman.com/t/converting-from-xml-to-json/36462>\
**Category:** Help Hub\
**Tags:** scripts, response, xml-parsing\
**Created:** [June 22, 2022, 10:58am UTC](https://community.postman.com/t/converting-from-xml-to-json/36462 "2022-06-22T10:58:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![simens65](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@simens65](https://community.postman.com/u/simens65)\
**Post date:** [June 22, 2022, 10:58am UTC](https://community.postman.com/t/converting-from-xml-to-json/36462/1 "2022-06-22T10:58:51Z")

</div>

I’m new to Postman & API’s and wondering if anybody understands why  
this [XML file](https://big.btwentyfour.com/ORDERS_sample_B24c21.xml)…

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/8/8d8aac0830cfa9501cfd46b9ab119f0819170f2e.png)

Ends up like this:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/d/d19b3b919abf4a2173b057c83fc80f504ae5d986.png)

I suspect schema, but when I try to import the [schema](https://big.btwentyfour.com/b24c21-20220324.xsd), it fails.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 22, 2022, 5:41pm UTC](https://community.postman.com/t/converting-from-xml-to-json/36462/2 "2022-06-22T17:41:48Z")

</div>

Hi @simens65

When you say “Ends up like this:”… what is happening between image 1 and image 2?

Do you submit a GET/POST call, is it custom code, or importing files? etc.

---

<div class="post-metadata">

**Author:** ![simens65](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@simens65](https://community.postman.com/u/simens65)\
**Post date:** [June 28, 2022, 7:41am UTC](https://community.postman.com/t/converting-from-xml-to-json/36462/3 "2022-06-28T07:41:50Z")

</div>

Hi Pic 1 is the body I read as input

This is the test script:  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/0/0939bbeedf30eaf9ba6fd49804ba14a1a0c4b172.png)

Pic 2 is the result I get.

I don’t understand why the $ sign appears and even stranger it gets further down.  
As this shows, the value and parameter name has switched…  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/f/f1f7429061c353a48aaf8ac02595bcb50e10982a.png)

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 28, 2022, 1:40pm UTC](https://community.postman.com/t/converting-from-xml-to-json/36462/4 "2022-06-28T13:40:21Z")

</div>

I haven’t done much with XML in Postman, but maybe this will help… ?

According to the [NPM page](https://www.npmjs.com/package/xml2js), there is a prefix option.

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/2/23b2fff96869b61e3794199e00ab59b1e9883a05.png)

Some additional info that seems related…

> **[Attr.prefix - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Attr/prefix)**
>
> The read-only prefix property of the Attr returns the namespace prefix of the attribute, or null if no prefix is specified.

---

<div class="post-metadata">

**Author:** ![tim.carter](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tim.carter](https://community.postman.com/u/tim.carter)\
**Post date:** [November 27, 2023, 8:41pm UTC](https://community.postman.com/t/converting-from-xml-to-json/36462/5 "2023-11-27T20:41:47Z")

</div>

It’s kinda late for this response, but…

- ‘$’ is a pseudo-object to capture attributes
- postman xml2Json is not the same as nodejs equivalent … the only argument is the xml string, so you just have to use the ‘$’ key if you want to extract any attribute values.
