title: How to include Declaration with XElement.ToString()
body: <p>I am trying to write an XML response for my web service however I can't figure out how to make the declaration appear in the response. </p>
  
  <p>My code is like so : </p>
  
  <pre><code>StringBuilder sBuilder = new StringBuilder();
  using (XmlWriter writer = XmlWriter.Create(sBuilder))
  {
      writer.WriteStartDocument();
      writer.WriteStartElement("ReportResponse");
      Response.WriteXml(writer);
      writer.WriteEndElement();
      writer.WriteEndDocument();
  }
  
  var response = XElement.Parse(sBuilder.ToString());
  return response;
  </code></pre>
  
  <p>Response is just a POCO for storing response data. </p>
  
  <p>I am aware that the <code>Save</code> method includes the declaration and the <code>ToString()</code> method does not. I need to write my declaration back with <code>ToString()</code>. </p>
  
  <p>I really just want to return custom XML from my REST Service without casting my string 100 times to return valid XML. Is this even possible or am just spinning my wheels ?</p>