다음을 통해 공유


XmlRootAttribute.ElementName Property

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

Gets or sets the name of the XML element that is generated and recognized by the XmlSerializer class's Serialize and Deserialize methods, respectively.

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

Syntax

'Declaration
Public Property ElementName As String
public string ElementName { get; set; }

Property Value

Type: System.String
The name of the XML root element that is generated and recognized in an XML-document instance. The default is the name of the serialized class.

Remarks

Specify an ElementName if you want the name of the generated XML element to differ from the class name.

Examples

The following example creates an instance of the XmlRootAttribute class and sets the ElementName property to a new value. The object is then used to create an XmlAttributeOverrides object used to override the serialization of an object.

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.