I would like to open a new window after a click event and show an xml structure. I do not want that browser interpret my xml.
I tried with this:
window.open('data:text/xml;charset=utf-8,<?xml version="1.0" encoding="UTF-8"?><RootTag>'+xml+'</RootTag>', "", "_blank")
with chrome this do not work.
You have two questions here
To open a window either use a popup / modal control (for example NgBootstrap Modal ) or use angular routing to navigate to a different page.
To just show xml write it in interpolation. Something like this.
<div style="white-space:pre; font-size:12px; font-family:monospace;">{{getXML()}}</div>
and in the component,
getXML() { return "<RootTag>xml</RootTag>"; }
Please find sample code .
I solved this problem with this code in the component.ts
let blob = new Blob([text], {type: 'text/xml'});
let url = URL.createObjectURL(blob);
window.open(url);
URL.revokeObjectURL(url);
This open a new window with the view just for xml.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.