XmlSerializer Constructor (Type, XmlRootAttribute)

May 11, 2014

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
)

Parameters

type
Type: System.Type
The type of the object that this XmlSerializer can serialize.
root
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.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft