title: c# whitespaces issue with XmlReader
body: <p>I have a simple xml</p>
  
  <pre><code>&lt;data&gt;
      &lt;node1&gt;value1&lt;/node1&gt;
      &lt;node2&gt;value2&lt;/node2&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>I'm using IXmlSerializable to read and write such xml with DTOs. The following code works just fine</p>
  
  <pre><code>XmlReader reader;
  ...
  while( reader.Read() ){
      Console.Write( reader.ReadElementContentAsString() );
  }
  // outputs value1value2
  </code></pre>
  
  <p>However, if whitespaces in the xml are removed, i.e. </p>
  
  <pre><code>&lt;data&gt;
      &lt;node1&gt;value1&lt;/node1&gt;&lt;node2&gt;value2&lt;/node2&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>or I use <code>XmlReaderSettings.IgnoreWhitespace = true;</code>, the code outputs only "value1" ignoring the second node. When I print the nodes that the parser traverses, I can see that <code>ReadElementContentAsString</code> moves the pointer to the <code>EndElement</code> of <code>node2</code>, but I don't understand why that should be happening or how to fix it.</p>
  
  <p>Is it a possible XML parser implementation bug?</p>
  
  <p>===============================================</p>
  
  <p>Here's a sample code and 2 xml samples that produce different results</p>
  
  <pre><code>string homedir = Path.GetDirectoryName(Application.ExecutablePath);
  string xml = Path.Combine( homedir, "settings.xml" );
  
  FileStream stream = new FileStream( xml, FileMode.Open );
  
  XmlReaderSettings readerSettings = new XmlReaderSettings();
  readerSettings.IgnoreWhitespace = false;
  XmlReader reader = XmlTextReader.Create( stream, readerSettings );
  
  while( reader.Read() ){
  
      if ( reader.MoveToContent() == XmlNodeType.Element &amp;&amp; reader.Name != "data" ){
  
          System.Diagnostics.Trace.WriteLine(
              reader.NodeType 
              + " "
              + reader.Name
              + " " 
              + reader.ReadElementContentAsString()
          );
      }
  }
  
  stream.Close(); 
  </code></pre>
  
  <p>1.) settings.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;data&gt;
      &lt;node-1&gt;value1&lt;/node-1&gt;
      &lt;node-2&gt;value2&lt;/node-2&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>2.) settings.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;data&gt;
      &lt;node-1&gt;value1&lt;/node-1&gt;&lt;node-2&gt;value2&lt;/node-2&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>using (1) prints</p>
  
  <pre><code>Element node-1 value1
  Element node-2 value2
  </code></pre>
  
  <p>using (2) prints</p>
  
  <pre><code>Element node-1 value1
  </code></pre>