Good morning.
I have a webpage with a form that generates a XML Document with DOMparser(). That's the function to get the XML:
function textToXML(text) {
try {
var xml = null;
if (window.DOMParser) {
var parser = new DOMParser();
xml = parser.parseFromString(text, "application/xml");
var found = xml.getElementsByTagName("parsererror");
if (!found || !found.length || !found[0].childNodes.length) {
return xml;
}
return null;
} else {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.loadXML(text);
return xml;
}
} catch (e) {
// suppress
}
}
And I get a XML document like (displayed on console.log()):
And I don't know how could I download it now, I have tried with
location.href='data:application/download,' + encodeURIComponent(xmlFile)
but the downloaded file just show something like "[object] Object".
I GOT IT. Finally I was searching for a plugin and I got this https://github.com/eligrey/FileSaver.js !! I hope it help somebody more than me! Thanks for try to help me!