title: Error: The XML declaration must be the first node in the document
body: <p>I am getting "Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it" error while trying to load xml. Both my C# code and contents of XML file are given below. XML definition exists in Line 6 of the xml file and hence the error. </p>
  
  <p>I can not control what's there in the xml file so how can I edit/rewrite it using C# such that xml declaration comes first and then the comments to load it without any error!</p>
  
  <pre><code>//xmlFilepath is the path/name of the xml file passed to this function
  static function(string xmlFilepath)
  {
  XmlReaderSettings readerSettings = new XmlReaderSettings();
  readerSettings.IgnoreComments = true;
  readerSettings.IgnoreWhitespace = true;
  XmlReader reader = XmlReader.Create(XmlFilePath, readerSettings);
  XmlDocument xml = new XmlDocument();
  xml.Load(reader);
  }
  </code></pre>
  
  <p>XmlDoc.xml</p>
  
  <pre><code>&lt;!-- Customer ID: 1 --&gt;
  &lt;!-- Import file: XmlDoc.xml --&gt;
  &lt;!-- Start time: 8/14/12 3:15 AM --&gt;
  &lt;!-- End time: 8/14/12 3:18 AM --&gt;
  
  &lt;?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?&gt;
  -----
  </code></pre>