I\'m given a xsd generated C# POCO object that I need to convert to xml. The expected payload however doesn\'t match the xsds I was given. Specifically, I need to omit the
This is another solution:
XmlWriterSettings settings = new XmlWriterSettings();
//If you wish Encoding
settings.Encoding = Encoding.GetEncoding("ISO-8859-1");
using (XmlWriter xmlWriter = XmlWriter.Create(tempFilePath, settings))
{
var ns = new XmlSerializerNamespaces();
ns.Add("", "http://thecompany.com");
XmlSerializer s = new XmlSerializer(YOUROBJECT.GetType(), "http://thecompany.com");
s.Serialize(xmlWriter, YOUROBJECT, ns);
}