The page has been moved to GitHub

XmlSerialization

Package: MyToolkit
Platforms: All (PCL)

Used to serialize and deserialize an object to XML (using the .NET XML serializer). By default, the serializers are internally cached to improve the serialization process for multiple objects of the same type.

var person = new Person();
...
var xml = XmlSerialization.Serialize(person);
var person2 = XmlSerialization.Deserialize<Person>(xml);

Note: Use the BCL .NET XmlAttribute, XmlTag, XmlIgnore, etc attributes to control the serialization process...

If you have circular references use the DataContractSerialization class and the preserveReferences option because the XML serializer does not support circular references and will eventually throw a StackOverflowException.

Additional methods:
  • SerializeAsync
  • DeserializeAsync

Last edited Jun 3, 2015 at 10:01 PM by rsuter, version 11