title: Add <?xml version="1.0" ?> to the top of a xml file after xsl transform
body: <p>I have successfully been able to transform a simple xml file with data to another xml file (excel template) using a xsl template, this is what my xsl file looks like:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
    &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
    &lt;xsl:output method="xml" standalone="yes"/&gt;
  
      &lt;xsl:template match="/"&gt;
        &lt;xsl:processing-instruction name="mso-application"&gt;
          &lt;xsl:text&gt;progid="Excel.Sheet"&lt;/xsl:text&gt;
        &lt;/xsl:processing-instruction&gt;
      ...(stuff here)...
      &lt;/xsl:template&gt;
    &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The resulting xml file is written out correctly BUT with the exception of including</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  </code></pre>
  
  <p>at the top of the file. How can I get it to appear at the top?</p>
  
  <p>Currently my resulting xml file starts with:</p>
  
  <pre><code>&lt;?mso-application progid="Excel.Sheet"?&gt;
  ...(rest of file)...
  </code></pre>
  
  <p>But what I need it to do is:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?mso-application progid="Excel.Sheet"?&gt;
  .(rest of file)...
  </code></pre>
  
  <p>I'm doing this transform through a windows form with the following code:</p>
  
  <pre><code>XPathDocument myXPathDoc = new XPathDocument(xmlfile);
  XslCompiledTransform myXslTrans = new XslCompiledTransform();
  myXslTrans.Load(xslfile);
  XmlTextWriter myWriter = new XmlTextWriter(xmlexcelfile, null);
  myWriter.Formatting = Formatting.Indented;
  myWriter.Namespaces = true;
  myXslTrans.Transform(myXPathDoc, null, myWriter);
  myWriter.Close();
  </code></pre>
  
  <p>I've tried playing around with the <code>xsl:output standalone="yes/no"</code>, as well as <code>omit-xml-declaration="no"</code>. I've also tried (in the C#) code adding <code>myWriter.WriteStartDocument();</code> before transforming but that was not allowed. I have tried searching online for this as well and keep coming back to the <code>standalone="yes"</code> but that isn't working. Is there something I am missing here? Oh and in case you are wondering why I need to have the</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  </code></pre>
  
  <p>at the top of the resulting file, it's because when opening the xml file with excel, excel doesn't recognize it correctly but if it is included then excel opens it correctly...</p>