I want to serialize a class to xml and store that in a field in a database. I can serialize with this:
StringWriter sw = new StringWriter();
XmlSerializer xmlser = new XmlSerializer(typeof(MyClass));
xmlser.Serialize(sw, myClassVariable);
string s = sw.ToString();
sw.Close();
Thats works, but it has the namespaces in it.
<.... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Will these slow down the deserialization because it will go out to those and verify the XML? I got rid of the namespaces by creating a blank XmlSerializerNamespaces and using that to serialize, but then the xml still had namespaces around integer variables:
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema"
d3p1:type="q1:int"
xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance">
3
</anyType>
My question is: Is it necessary to have the namesapces for deserialization and if not, how to get rid of them? How do I tell it fields are ints so it doesnt put in "anytype"
Thanks, Brian