title: XmlWriter inserting spaces when xml:space=preserve
body: <p>Given this code (C#, .NET 3.5 SP1):</p>
  
  <pre><code>var doc = new XmlDocument();
  doc.LoadXml("&lt;?xml version=\"1.0\"?&gt;&lt;root&gt;"
      + "&lt;value xml:space=\"preserve\"&gt;"
      + "&lt;item&gt;content&lt;/item&gt;"
      + "&lt;item&gt;content&lt;/item&gt;"
      + "&lt;/value&gt;&lt;/root&gt;");
  
  var text = new StringWriter();
  var settings = new XmlWriterSettings() { Indent = true, CloseOutput = true };
  using (var writer = XmlWriter.Create(text, settings))
  {
      doc.DocumentElement.WriteTo(writer);
  }
  
  var xml = text.GetStringBuilder().ToString();
  Assert.AreEqual("&lt;?xml version=\"1.0\" encoding=\"utf-16\"?&gt;\r\n&lt;root&gt;\r\n"
      + "  &lt;value xml:space=\"preserve\"&gt;&lt;item&gt;content&lt;/item&gt;"
      + "&lt;item&gt;content&lt;/item&gt;&lt;/value&gt;\r\n&lt;/root&gt;", xml);
  </code></pre>
  
  <p>The assertion fails because the <code>XmlWriter</code> is inserting a newline and indent around the <code>&lt;item&gt;</code> elements, which would seem to contradict the <code>xml:space="preserve"</code> attribute.</p>
  
  <p>I am trying to take input with no whitespace (or only significant whitespace, and already loaded into an <code>XmlDocument</code>) and pretty-print it <em>without</em> adding any whitespace inside elements marked to preserve whitespace (for obvious reasons).</p>
  
  <p>Is this a bug or am I doing something wrong?  Is there a better way to achieve what I'm trying to do?</p>
  
  <p><strong>Edit</strong>: I should probably add that I do have to use an <code>XmlWriter</code> with <code>Indent=true</code> on the output side.  In the "real" code, this is being passed in from outside of my code.</p>