I would like to be able to view xml data using any browser's native xml formatting. Similar to opening a local xml file in a browser.
I do not need anything else on the web page other than the xml data.
var xmlString = document.getElementById("xmlDivContent" + name).innerText;
window.open("data:text/xml;charset=utf-8," + xmlString, "", "_blank");
I've searched around, extensively, for a solution to this problem...I'm not interested in using XSLT or any "home-rolled" formatting function because I just want to take advantage of the browser's built-in xml formatting.
This is possible using the Blob APIs:
let blob = new Blob(['<yourxmlstringhere></yourxmlstringhere>'], {type: 'text/xml'});
let url = URL.createObjectURL(blob);
window.open(url);
URL.revokeObjectURL(url); //Releases the resources
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With