Is there any way to show Raw XML data in Popup without default alert box?

116 Views Asked by At

I want to show raw XML data with tags in Popups like Bootstrap Modal, BootBox, jAlert, SweetAlert2, or SweetAlert.
But when I feed the raw XML data, those libraries only show the content inside the tags.
I want something like

<Account>
    <Name>Customer Name</Name>
    <Balance>Current Balance</Balance>
</Account>

But those libraries show only

Customer Name
Current Balance

Only the default alert dialog box shows the content with XML tags.
I was trying to fix this issue by replacing using jQuery

< with &lt; and > with &gt;

But my team lead says not to change any data by any means.
Is there any plugin or any way to show raw XML with a beautiful alert box?

1

There are 1 best solutions below

4
kjhughes On

To answer the question asked in your title,

Is there any way to show Raw XML data in Popup with default alert box?

Yes, the default JavaScript alert(),

alert(`<Account>
    <Name>Customer Name</Name>
    <Balance>Current Balance</Balance>
</Account>`)

will show raw XML data:

enter image description here

See also