title: How to Make XDocument keep new line in attributes like XmlDocument does?
body: <p>I am using XDocument and LINQ with great ease and comfort, but<br>
  one problem arises:  </p>
  
  <p>XDocument <strong>removes new lines</strong> inside attribute when you try to output back the xml.<br>
  XmlDocument on the other hand, <strong>keeps the new line</strong>.</p>
  
  <pre class="lang-cs prettyprint-override"><code>static void Main(string[] args)
  {
      string res;
      string str = "&lt;element attrib='Some text \n with new line'/&gt;";
  
      XDocument xDoc = XDocument.Parse(str);
      res = xDoc.ToString();
      //res dose not containe the new line.
  
      XmlDocument xmlDoc = new XmlDocument();
      xmlDoc.LoadXml(str);
      res = xmlDoc.OuterXml;
      //res contains a new line char, that i can replace to something more nice like /r.
      res = res.Replace("&amp;#xA;", Environment.NewLine);
  }
  </code></pre>
  
  <p>I have a lot of code already written with XDocument, and don't want to rewrite it using XmlDocument. How can I get XDocument to behave like XmlDocument it this manner?</p>