javascript - How can I download a XML #document generated by DOMparser? -
good morning.
i have webpage form generates xml document domparser(). that's function 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 xml document (displayed on console.log()):
and don't know how download now, have tried with
location.href='data:application/download,' + encodeuricomponent(xmlfile)
but downloaded file show "[object] object".
i got it. searching plugin , got https://github.com/eligrey/filesaver.js !! hope more me! try me!
Comments
Post a Comment