title: XDocument Text Node New Line
body: <p>I'm trying to get a newline into a text node using <code>XText</code> from the Linq XML namespace.</p>
  
  <p>I have a string which contains newline characters however I need to work out how to convert these to entity characters (i.e. <code>&amp;#10;</code>) rather than just having them appear in the XML as new lines.</p>
  
  <pre><code>XElement element = new XElement( "NodeName" );
  ...
  
  string example = "This is a string\nWith new lines in it\n";
  
  element.Add( new XText( example ) );
  </code></pre>
  
  <p>The <code>XElement</code> is then written out using an <code>XmlTextWriter</code> which results in the file containing the newline rather than an entity replacement.</p>
  
  <p>Has anyone come across this problem and found a solution?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The problem manifests itself when I load the XML into EXCEL which doesn't seem to like the newline character but which accepts the entity replacement. The result is that newlines aren't showing in EXCEL unless I replace them with <code>&amp;#10;</code></p>
  
  <p>Nick.</p>