Use an <a href>
(html5) like:
<a href="downloads/file.xml" download>Download File</a>
And if you like to create an XML file in javascript and then save it by an a tag you can do:
var xml = '<xml><node1>bla</node1><node2 var="aa">abla</node2></xml>';
xml = btoa(xml); // Converts xml string to base64 (use atob to convert base64 back to string)
var a = document.createElement('a'); // Create A element
a.href = 'data:text/xml;base64,' + xml; // Set base64 encoded href
a.setAttribute('download', ''); // add html5 download tag
a.appendChild(document.createTextNode('download xml file'); // Add link text
body.appendChild(a); // And add element to the page.
Paste this code in a html file and see for your self :)
Note: this code might not work in all browsers, tested with IE11 and Chrome