I've done the following to display my xml into a new browser window:
window.open('data:text/xml,' + encodeURIComponent( '<?xml version="1.0" encoding="utf-8"?><Document xmlns:xsi="" xmlns:xsd="" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"><parent>test</parent></Document>' ));
works great in all browsers... but IE obviously. I'm using IE10. What should I do to get this to work ? Right now, the xml is URL encoded and does not show up in the new window.
I've done the following to display my xml into a new browser window:
window.open('data:text/xml,' + encodeURIComponent( '<?xml version="1.0" encoding="utf-8"?><Document xmlns:xsi="http://www.w3/2001/XMLSchema-instance" xmlns:xsd="http://www.w3/2001/XMLSchema" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"><parent>test</parent></Document>' ));
works great in all browsers... but IE obviously. I'm using IE10. What should I do to get this to work ? Right now, the xml is URL encoded and does not show up in the new window.
Share Improve this question edited Jul 11, 2013 at 15:06 Sam asked Jul 11, 2013 at 14:12 SamSam 14.6k32 gold badges114 silver badges203 bronze badges 2-
For IE I think you will need to bounce it back to the server. There is
window.open('javascript:document.write("' + "hello" + '")');
but I think you will have issues getting it to work with xml – Alex K. Commented Jul 11, 2013 at 14:28 - docuemnt.write implies that I format the xml by myself. I want to let the browser do that. Sounds like a pain indeed.... – Sam Commented Jul 11, 2013 at 14:44
2 Answers
Reset to default 4From the data Protocol article in the MSDN library:
For security reasons, data URIs are restricted to downloaded resources. Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements.
For security reasons, data URIs are restricted to downloaded resources. Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements...
They can with this Javascript trick..
var uri = 'data:text/xml,' + encodeURIComponent({your xml});
var link = document.createElement("a");
link.href = uri;
link.style = "visibility:hidden";
link.download = fileName + ".xml";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);