title: write compressed xml data to a memory stream using gzipstream
body: <p>I am trying to write a compressed xml data to a memory stream. Here is my test console app code:</p>
  
  <pre><code>var ms = new MemoryStream();
  var gstream = new GZipStream(ms, CompressionMode.Compress);
  
  var settings = new XmlWriterSettings();
  settings.Indent = true;
  
  var writer = XmlWriter.Create(gstream, settings);
  writer.WriteStartElement("x", "root", "123");
  writer.WriteStartElement("item");
  writer.WriteAttributeString("xmlns", "x", null, "abc");
  writer.WriteEndElement();
  writer.WriteEndElement();            
  
  Console.WriteLine("Data length: " + ms.ToArray().Length);
  
  writer.Close();
  gstream.Close();
  ms.Close();    
  
  Console.ReadLine();
  </code></pre>
  
  <p>And the output is:</p>
  
  <pre><code>Data length: 0
  </code></pre>
  
  <p>What am i doing wrong? Thank you.</p>