XmlSerializer Constructor (Type, XmlRootAttribute)

XmlSerializer Constructor (Type, XmlRootAttribute)

Initializes a new instance of the XmlSerializer class that can serialize objects of the specified type into XML documents and deserialize an XML document into object of the specified type. It also specifies the class to use as the XML root element.

Namespace:  System.Xml.Serialization
Assembly:  System.Xml.Serialization (in System.Xml.Serialization.dll)

public XmlSerializer(
	Type type,
	XmlRootAttribute root


Type: System.Type
The type of the object that this XmlSerializer can serialize.
Type: System.Xml.Serialization.XmlRootAttribute
An XmlRootAttribute that represents the XML root element.

The root element of an XML document encloses all the other elements. By default, the object specified by the type parameter is serialized as the root element. Properties, such as the XML element name of the root element, are taken from the type object. However, the root parameter allows you to replace the default object's information by specifying an XmlRootAttribute. The object allows you to set a different namespace, element name, and so on.


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

© 2015 Microsoft