Removing the XML namespace and declaring headers does not affect deserialization.
Directly on the code:
Serialization of this object
int obj = 1;
XmlSerializer serializer = new XmlSerializer (obj. GetType ());
Serializes an object to a file
FileStream stream = new FileStream ("Hh.xml", FileMode.Create);
XmlWriterSettings settings = new XmlWriterSettings ();
Settings. Indent = true;
Settings. IndentChars = " ";
Settings. Newlinechars = "\ r \ n";
Settings. Encoding = Encoding.UTF8;
Settings. Omitxmldeclaration = true; Do not generate the declaration header
using (XmlWriter XmlWriter = XmlWriter.Create (stream, settings))
{
//force the specified namespace to override the default namespace
xmlserializernamespaces namespaces = new XmlSerializerNamespaces ();
namespaces. ADD (String. Empty, String. Empty);
Serializer. Serialize (XmlWriter, obj, namespaces);
Xmlwriter.close ();
};
Stream. Close ();