Freigeben über


XmlSerializer Constructor (Type, XmlRootAttribute)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Sub New ( _
    type As Type, _
    root As XmlRootAttribute _
)
public XmlSerializer(
    Type type,
    XmlRootAttribute root
)

Parameters

Remarks

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.

Version Information

Silverlight

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

Platforms

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