# Display XML response

**URL:** <https://community.postman.com/t/display-xml-response/53069>\
**Category:** Help Hub\
**Tags:** tests, response, xml\
**Created:** [October 10, 2023, 1:28pm UTC](https://community.postman.com/t/display-xml-response/53069 "2023-10-10T13:28:01Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![hendaderbali](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hendaderbali](https://community.postman.com/u/hendaderbali)\
**Post date:** [October 10, 2023, 1:28pm UTC](https://community.postman.com/t/display-xml-response/53069/1 "2023-10-10T13:28:01Z")

</div>

Hello  
Can anyone help me to solve this issue ?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/f/af6e70f3431b85d8f95c51203a9d2ef9d6446a15.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/1/b1bd3ed304ac4259a34e6213f7eea78fb36fa417.png)  
I use all solution to diplay \< in place of &lt but it does not work  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/6/f/6f4d478b0df9e4ef6997593b514fef3759dde059.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 10, 2023, 2:38pm UTC](https://community.postman.com/t/display-xml-response/53069/2 "2023-10-10T14:38:30Z")

</div>

Hey @hendaderbali 👋

Welcome to the Postman Community! :postman:

How are you planning on using the modified response body?

In your code you have `pm.response.text(modifiedResponseBody)`, which isn’t the correct syntax as that function doesn’t take an argument.

If you could provide more context and information, it will be easier to help you out here. 🙏

---

<div class="post-metadata">

**Author:** ![hendaderbali](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hendaderbali](https://community.postman.com/u/hendaderbali)\
**Post date:** [October 10, 2023, 2:53pm UTC](https://community.postman.com/t/display-xml-response/53069/3 "2023-10-10T14:53:01Z")

</div>

i am using c data xml request ,  
but response does not contains ‘\<’ int return this ‘&lt’ and this ‘&#xD’ ;

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 10, 2023, 4:51pm UTC](https://community.postman.com/t/display-xml-response/53069/4 "2023-10-10T16:51:19Z")

</div>

You can’t edit the response like you can with the request using pre-request scripts and pm.request.body.

It’s static\read only. The response is what the API returned, you can’t edit it.

You can parse the response to text() or use the cheerio library.

Your replace command should work (but if not, there are dozens of topics on the subject if you search the interweb). Postman uses JavaScript in the tests tab, so you just need to include that in your search.

At which point, you can console log the updated parsed response (but you can’t change the actual response).

As Danny mentioned. What are you trying to do with this?

“&lt” is the escaped version of “\<”.

---

<div class="post-metadata">

**Author:** ![hendaderbali](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hendaderbali](https://community.postman.com/u/hendaderbali)\
**Post date:** [October 11, 2023, 7:11am UTC](https://community.postman.com/t/display-xml-response/53069/5 "2023-10-11T07:11:12Z")

</div>

Just i want to keep my response but displayed with \<\> and not &lt

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 11, 2023, 9:44am UTC](https://community.postman.com/t/display-xml-response/53069/6 "2023-10-11T09:44:14Z")

</div>

I appreciate that, but unless you can get your API to return the response without escaped characters, then this isn’t going to work.

On a side note, what does the response start with? Is it a string (with the whole response wrapped in quotes)?

---

<div class="post-metadata">

**Author:** ![hendaderbali](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hendaderbali](https://community.postman.com/u/hendaderbali)\
**Post date:** [October 11, 2023, 3:07pm UTC](https://community.postman.com/t/display-xml-response/53069/7 "2023-10-11T15:07:30Z")

</div>

this is the begin of request 🙂

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

And this is the begin of REsponse :

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/3/c3661058d1951bc406c46fa8190e080b211dee2f.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 11, 2023, 3:29pm UTC](https://community.postman.com/t/display-xml-response/53069/8 "2023-10-11T15:29:39Z")

</div>

What are the response headers that are returned?

Are you manually setting that content type as `XML` because `Auto` isn’t picking up the correct content type header?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 11, 2023, 4:17pm UTC](https://community.postman.com/t/display-xml-response/53069/9 "2023-10-11T16:17:32Z")

</div>

@danny-dainton

If the content headers are correct, are we expecting the pretty print to automatically format the special characters?

I was wondering if the whole XML was wrapped in a string, but it appears to be ok.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 11, 2023, 4:21pm UTC](https://community.postman.com/t/display-xml-response/53069/10 "2023-10-11T16:21:18Z")

</div>

My thinking was about seeing the response headers, was around noticing the content type had been manually changed in the response pane.

It could be a red herring but it caught my eye and I was wondering why that needed to be changed 🤔

---

<div class="post-metadata">

**Author:** ![hendaderbali](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hendaderbali](https://community.postman.com/u/hendaderbali)\
**Post date:** [October 12, 2023, 1:29pm UTC](https://community.postman.com/t/display-xml-response/53069/11 "2023-10-12T13:29:34Z")

</div>

so it is impossible to change it ??

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 12, 2023, 1:53pm UTC](https://community.postman.com/t/display-xml-response/53069/12 "2023-10-12T13:53:42Z")

</div>

Any script that you create in the `Tests` section is executed _after_ the response is received from the server - It’s not going to change anything you see in the response pane.

I still don’t really know what you are expecting to see in the UI, as a result of running a script. I believe that part of your question is still unclear.

Using this API as an example of returning XML, just to show it doesn’t happen on every API:

```auto
https://random-data-api.com/api/v2/users?size=2&is_xml=true&response_type=xml

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/e/9e4497f4fc9b977ab70deee642e1f9912fed9cec.jpeg)

Do you see the same encoding if you call the service using cURL from the command line?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 12, 2023, 4:12pm UTC](https://community.postman.com/t/display-xml-response/53069/13 "2023-10-12T16:12:37Z")

</div>

> [@danny-dainton](#):
>
> Do you see the same encoding if you call the service using cURL from the command line?

I’m assuming at this point (perhaps incorrectly) that its the API that is sending it back escaped.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [November 11, 2023, 4:13pm UTC](https://community.postman.com/t/display-xml-response/53069/14 "2023-11-11T16:13:01Z")

</div>

Closed on November 11, 2023, 4:13pm UTC

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