Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

System.Xml.Serialization Namespace

The System.Xml.Serialization namespace contains classes that are used to serialize objects into XML format documents or streams.

The central class in the namespace is the XmlSerializer class. To use this class, use the XmlSerializer constructor to create an instance of the class using the type of the object to serialize. Once an XmlSerializer is created, create an instance of the object to serialize. You must also create an object to write the file to a document or stream, such as a Stream, TextWriter, or XmlWriter. You can then call the Serialize method to convert the object into an XML document.

To deserialize an object from an XML document, create a suitable object to read the document or stream (again, a Stream, TextWriter, or XmlWriter). Invoke the Deserialize method while casting the resulting object to the type of the original object (that was serialized).

To further control the serialization, the System.Xml.Serialization namespace contains several Attribute classes that can be applied to members of a class. For example, if a class contains a member that will be serialized as an XML element, you can apply the XmlElementAttribute attribute to the member. When applying the attribute, you can specify details such as the actual XML element name using the ElementName property. For a complete list of all the attributes, see the XmlSerializer class overview.

Namespace hierarchy

Classes

Class Description
SoapAttributeAttribute Specifies that the XmlSerializer should serialize the class member as an encoded SOAP attribute.
SoapAttributeOverrides Allows you to override property, field, and class attributes when you use an XmlSerializer to serialize or deserialize an object as encoded SOAP.
SoapAttributes Represents a collection of attribute objects that control how the XmlSerializer serializes and deserializes SOAP methods.
SoapElementAttribute Specifies that the public member value be serialized by the XmlSerializer as an encoded SOAP XML element.
SoapEnumAttribute Controls how the XmlSerializer serializes an enumeration member.
SoapIgnoreAttribute Instructs the XmlSerializer not to serialize the public field or public read/write property value.
SoapIncludeAttribute Allows the XmlSerializer to recognize a type when it serializes or deserializes an object as encoded SOAP XML.
SoapTypeAttribute Controls the schema generated by the XmlSerializer when a class instance is serialized as SOAP encoded XML.
UnreferencedObjectEventArgs Provides data for the known, but unreferenced, object found in an encoded SOAP XML stream during deserialization.
XmlAnyAttributeAttribute Specifies that the member (a field that returns an array of XmlAttribute objects) can contain any XML attributes.
XmlAnyElementAttribute Specifies that the member (a field that returns an array of XmlElement or XmlNode objects) can contain objects that represent any XML element that has no corresponding member in the object being serialized or deserialized.
XmlAnyElementAttributes Represents a collection of XmlAnyElementAttribute objects.
XmlArrayAttribute Specifies that the XmlSerializer should serialize a particular class member as an array of XML elements.
XmlArrayItemAttribute Specifies the derived types that the XmlSerializer can place in a serialized array.
XmlArrayItemAttributes Represents a collection of XmlArrayItemAttribute objects.
XmlAttributeAttribute Specifies that the XmlSerializer should serialize the class member as an XML attribute.
XmlAttributeEventArgs Provides data for the UnknownAttribute event.
XmlAttributeOverrides Allows you to override property, field, and class attributes when you use the XmlSerializer to serialize or deserialize an object.
XmlAttributes Represents a collection of attribute objects that control how the XmlSerializer serializes and deserializes an object.
XmlChoiceIdentifierAttribute Specifies that the member can be further disambiguated by using an enumeration.
XmlElementAttribute Indicates that a public field or property represents an XML element when the XmlSerializer serializes or deserializes the containing object.
XmlElementAttributes Represents a collection of XmlElementAttribute, which the XmlSerializer uses to override the default way it serializes a class.
XmlElementEventArgs Provides data for the UnknownElement event.
XmlEnumAttribute Controls how the XmlSerializer serializes an enumeration member.
XmlIgnoreAttribute Instructs the Serialize method of the XmlSerializer not to serialize the public field or public read/write property value.
XmlIncludeAttribute Allows the XmlSerializer to recognize a type when it serializes or deserializes an object.
XmlNamespaceDeclarationsAttribute Specifies that the target property, parameter, return value or class member contains prefixes associated with namespaces that are used within an XML document.
XmlNodeEventArgs Provides data for the UnknownNode event.
XmlRootAttribute Controls XML serialization of the attribute target as an XML root element.
XmlSerializer Serializes and deserializes objects into and from XML documents. The XmlSerializer enables you to control how objects are encoded into XML.
XmlSerializerNamespaces Contains the XML namespaces and prefixes that the XmlSerializer uses to generate qualified names in an XML-document instance.
XmlTextAttribute Indicates to the XmlSerializer that the member should be treated as XML text when the containing class is serialized or deserialized.
XmlTypeAttribute Controls the XML schema generated when the attribute target is serialized by the XmlSerializer.
XmlTypeMapping Contains a mapping of one type to another.

Delegates

Delegate Description
UnreferencedObjectEventHandler Represents the method that will handle the UnreferencedObject event of an XmlSerializer.
XmlAttributeEventHandler Represents the method that will handle the UnknownAttribute
XmlElementEventHandler Represents the method that will handle the UnknownElement event of an XmlSerializer.
XmlNodeEventHandler Represents the method that will handle the UnknownNode event of an XmlSerializer.

See Also

.NET Framework Class Library

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft