Use the following code:
//Create our own namespaces for the output
XmlSerializerNamespaces ns = new XmlSerializerNamespaces ();
//Add an empty namespace and empty value
ns.Add ("", "");
//Create the serializer
XmlSerializer slz = new XmlSerializer (someType);
//Serialize the object with our own namespaces (notice the overload)
slz.Serialize (myXmlTextWriter, someObject, ns);
In addition, the comment also mentions removing the beginning <? XML version = "1.0" encoding = "UTF-8"?> Method:
Xmlwritersettings settings = new xmlwritersettings ();
// Remove the <? XML version = "1.0" encoding = "UTF-8"?>
Settings. omitxmldeclaration = true;
Xmlwriter writer = xmlwriter. Create ("output_file_name.xml", settings );
In addition, if encoding = "UTF-8" is not started, use:
Xmlwritersettings settings = new xmlwritersettings ();
Settings. Encoding = encoding. utf8;
Xmlwriter writer = xmlwriter. Create ("output_file_name.xml", settings );