<a id="link" download>xxxx</a> <script> var txt = '<?xml version="1.0" encoding="utf-8"?><root><name>NAME DOC</name></root>'; link.href = URL.createObjectURL(new Blob([txt], { type: "text/xml" })); </script>