XML Serialization/Deserialization

General Definition

The object is serialized to a stream, which carries not just the data, but information about the object’s type, such as its version, culture, and assembly name. From that stream, it can be stored in a database, a file, or memory.

  • XML serialization serializes the public fields and properties of an object, or the parameters and return values of methods, into an XML stream that conforms to a specific XML Schema definition language (XSD) document.
  • XML serialization results in strongly typed classes with public properties and fields that are converted to XML.
  • System.Xml.Serialization contains the classes necessary for serializing/deserializing XML. You can apply attributes to classes and class members in order to control the way the XmlSerializer serializes/deserializes an instance of the class.

Examples

Class example:

Deserialize example:

Serialize example: