title: How to put an encoding attribute to xml other that utf-16 with XmlWriter?
body: <p>I've got a function creating some XmlDocument:</p>
  
  <pre><code>public string CreateOutputXmlString(ICollection&lt;Field&gt; fields)
  {
      XmlWriterSettings settings = new XmlWriterSettings();
      settings.Indent = true;
      settings.Encoding = Encoding.GetEncoding("windows-1250");
  
      StringBuilder builder = new StringBuilder();
      XmlWriter writer = XmlWriter.Create(builder, settings);
  
      writer.WriteStartDocument();
      writer.WriteStartElement("data");
      foreach (Field field in fields)
      {
          writer.WriteStartElement("item");
          writer.WriteAttributeString("name", field.Id);
          writer.WriteAttributeString("value", field.Value);
          writer.WriteEndElement();
      }
      writer.WriteEndElement();
      writer.Flush();
      writer.Close();
  
      return builder.ToString();
  }
  </code></pre>
  
  <p>I set an encoding but after i create XmlWriter it does have utf-16 encoding. I know it's because strings (and StringBuilder i suppose) are encoded in utf-16 and you can't change it.<br>
  So how can I easily create this xml with the encoding attribute set to "windows-1250"? it doesn't even have to be encoded in this encoding, it just has to have the specified attribute.</p>
  
  <p>edit: it has to be in .Net 2.0 so any new framework elements cannot be used.</p>