title: Add XDeclaration to XDocument after it's constructed
body: <p>I have an XmlSerializer which I use to Serialize an object to an XDocument.</p>
  
  <pre><code>var doc = new XDocument();
  using (var writer = doc.CreateWriter())
  {
     xmlSerializer.Serialize(writer, object);
  }
  </code></pre>
  
  <p>After this is done, I want to add a XDeclaration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  </code></pre>
  
  <p>I construct this XDeclaration as described below:</p>
  
  <pre><code>var decl = new XDeclaration("1.0", "UTF-8", "no");
  </code></pre>
  
  <p>However, when I try to add this XDeclartion to my XDocument, I get the following error:</p>
  
  <pre><code>System.ArgumentException : Non white space characters cannot be added to content.
  </code></pre>
  
  <p>I searched Google for some time but all I've found is adding the XDeclaration to the constructor of the XDocument which in my case (when filling it with a XmlWriter) is not acceptable.</p>