I'm having trouble serializing an xml, it's being generated with encoding="utf-16"
.
But xsd
is with encoding="utf-8"
, how do I get it to be generated with utf-8
?
var xml = string.Empty;
var serialize = new XmlSerializer(typeof(Consulta));
using (var strignWriter = new StringWriter())
{
using (var xmlWriter = XmlWriter.Create(strignWriter, new XmlWriterSettings { Indent = true }))
{
serialize.Serialize(xmlWriter, xmlConsulta);
xml = strignWriter.ToString();
}
}