title: Creating XML in C# with UTF8 encoding
body: <p>I know that there is a lot of tutorials about this and even answered questions here, but I have problem I'm trying to resolve for hours and I read almost everything here, but this still remains mistery for me. Please help:</p>
  
  <p>I'm creating XML, and it's created, but the problem is that encoding is UTF-16, and it should be UTF-8. This is what I tried so far, but still is UTF-16:</p>
  
  <pre><code>        var xmlText = new StringBuilder();
  
          using (var xml = XmlWriter.Create(xmlText))
          {
              xml.WriteStartDocument();
              xml.WriteStartElement("Weather");
  
  
              if (model.ModuleList[0] != null)
              {
                  foreach (var weather in model.ModuleList)
                  {
                      var AddProperty = new Action&lt;XmlWriter, ModuleModel&gt;((a, forc) =&gt;
                      {
                          xml.WriteStartElement("Forecast");
                          a.WriteElementString("Description", forc.Description);
                          a.WriteElementString("Date", forc.Date.ToString());
                          a.WriteElementString("MinTemp", forc.Min_Temp.ToString());
                          a.WriteElementString("MaxTemp", forc.Max_Temp.ToString());
                          a.WriteElementString("Pressure", forc.Pressure.ToString());
                          a.WriteElementString("Humidity", forc.Humidity.ToString());                           
                          xml.WriteEndElement();
                      });
                      AddProperty(xml, weather);
                  }
              }             
  
              xml.WriteEndElement();
              xml.WriteEndDocument();
          }
          var xmlresult = xmlText.ToString();
  </code></pre>
  
  <p>How to set encoding to my XML to UTF-8? Please help...  </p>