title: How can we create an XML file using Javascript and save it in local machine and devices?
body: <p>How can we create an XML file using Javascript and save it in the local machine/Device from the browser? Is it possible to save it in the Mobile devices(Android/iPhone etc.)? I don't want to use it as a native application for mobile devices and need to work as a common web application for both desktop and mobile devices. I have tried the following code, but it is not working in FireFox and working fine in Chrome.</p>
  
  <pre><code>function download(filename, text) {
  var elem = document.createElement('a');
  elem.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  elem.setAttribute('download', filename);
  elem.click();}    
  
  download('test.txt', 'Hello world!');
  </code></pre>
  
  <p>I have also gone through Downloadify, and it is working for desktop browsers as it need flash 10+ (<a href="https://github.com/dcneiner/Downloadify" rel="nofollow">https://github.com/dcneiner/Downloadify</a>) and not working for mobile devices especially for iPhone.</p>
  
  <p>And also tried FileSaver, but it is also not working in devices (<a href="https://github.com/eligrey/FileSaver.js" rel="nofollow">https://github.com/eligrey/FileSaver.js</a>).</p>
  
  <p>Is there any common library which can be used to create and save XML files in common desktop browsers and mobile devices(Android, iPhone etc.) </p>
  
  <p>Please get me some possible solutions which can be used for both desktop browsers and Mobile Devices. </p>
  
  <p>Thanks in advance.</p>