G
Guest
H
I was wondering if it possible for an object to serialize/deserialize itself from XML.
I'd be guessing that it would need to use the XmlSerializer class, but that seems to want to create a brand new object when deserializing. In my case I have an existing object that I'd like to pass some XML to for the object to repopulate its member variables. Similarly I'd like it to be able to populate an XML string from the values of its member variables. The member variables will be primitive types, plus possibly DateTime values (not sure if that's classed as a primitive type)
Another quirk: not all of the member variables will necessarily be in the XML used to deserialize the object. But the XmlSerializer class seems OK with this
Using the SerializationInfo class seems another option, but I don't know about it taking XML rather than it's own dictionary based data representation
Thanks for any hel
Ian
I was wondering if it possible for an object to serialize/deserialize itself from XML.
I'd be guessing that it would need to use the XmlSerializer class, but that seems to want to create a brand new object when deserializing. In my case I have an existing object that I'd like to pass some XML to for the object to repopulate its member variables. Similarly I'd like it to be able to populate an XML string from the values of its member variables. The member variables will be primitive types, plus possibly DateTime values (not sure if that's classed as a primitive type)
Another quirk: not all of the member variables will necessarily be in the XML used to deserialize the object. But the XmlSerializer class seems OK with this
Using the SerializationInfo class seems another option, but I don't know about it taking XML rather than it's own dictionary based data representation
Thanks for any hel
Ian