title: Handling windows newline with XmlReader
body: <p>Recently, I replaced XmlValidatingReader with XmlReader and use XmlReaderSettings to validate the xml with an xsd.</p>
  
  <pre><code>CustomData cd = null;
  using (Stream xsdStream = new FileStream(m_DXsdFile, FileMode.Open, FileAccess.Read, FileShare.Read))
  {
    XmlTextReader sr = new XmlTextReader(xsdStream);
    using (Stream xmlStream = new FileStream(m_DXmlFile, FileMode.Open, FileAccess.Read, FileShare.Read))
    {
      XmlReaderSettings settings = new XmlReaderSettings();
      settings.ValidationType = ValidationType.Schema;
      settings.Schemas.Add(null, sr);
      XmlReader reader = XmlReader.Create(xmlStream, settings);
  
      try
      {
        XmlSerializer xmlSerializer = CreateDefaultXmlSerializer(m_Type);
        cd = (CustomData)xmlSerializer.Deserialize(reader);
      }
  
    ...
  }
  
  XML:
  &lt;Column Name="Content"&gt;
    &lt;Data xsi:type="xsd:string"&gt; * info info info
  info info info
   info info info&lt;/Data&gt;
    &lt;Data xsi:type="xsd:string"&gt;/* This is a test */&lt;/Data&gt;
  &lt;/Column&gt;
  &lt;Column Name="ErrorNr"&gt;
    &lt;Data xsi:type="xsd:int"&gt;2&lt;/Data&gt;
    &lt;Data xsi:type="xsd:int"&gt;2&lt;/Data&gt;
    &lt;Data xsi:type="xsd:int"&gt;2&lt;/Data&gt;
  &lt;/Column&gt;
  </code></pre>
  
  <p><em>CreateDefaultXmlSerializer() is implemented as suggested here: <a href="https://stackoverflow.com/a/9416860/2107510">https://stackoverflow.com/a/9416860/2107510</a></em></p>
  
  <p>However, XmlReader normalizes all newlines and converts \r\n to \n. This is not appreciated by the multi line text boxes which now display one line instead of multiple lines.</p>
  
  <p>I tried using XmlWriterSettings.NewLineHandling.Entitize and it fixes my problem but this make the XML document no longer readable in e.g. wordpad or any other text editor. (<a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.newlinehandling.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.newlinehandling.aspx</a>)</p>
  
  <p><strong>How can I preserve the multi line strings without losing them due to normalization?</strong> (and without other nasty side effects)</p>