title: Export XML to Excel spreadsheet using Javascript/classic-ASP
body: <p>I'm trying to export XML data from a web page to a spreadsheet using javascript. So far I've just tried the very simple: </p>
  
  <pre><code>Sub Export
      Response.ContentType = "application/vnd.ms-excel"
      &lt;script&gt;            
           var XML = document.getElementById("xmldata");              
           window.open(XML);
      &lt;/script&gt;
  End Sub
  </code></pre>
  
  <p>This tries to open the XML file as an excel spreadsheet, however it doesn't open because it has invalid characters. I've tracked down these characters and the main culprit tends to be the horizontal dash "–". There may be other invalid characters, but If I remove them manually, the XML file opens fine. </p>
  
  <p>How would I go about formatting the XML content to remove or replace the invalid characters to display properly to excel? The XML sheet is built from fields in a database, should I format it as it's built or format it with javascript? I'm trying to find the simplest solution possible as I'm fairly new to web programming. Also, I'm using classic ASP/VBscript.</p>