Export (0) Print
Expand All

XmlElementAttribute.ElementName Property

Gets or sets the name of the generated XML element.

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

'Declaration
Public Property ElementName As String
'Usage
Dim instance As XmlElementAttribute
Dim value As String

value = instance.ElementName

instance.ElementName = value
/** @property */
public String get_ElementName ()

/** @property */
public void set_ElementName (String value)

public function get ElementName () : String

public function set ElementName (value : String)

Not applicable.

Property Value

The name of the generated XML element. The default is the member identifier.

Specify an ElementName if you want the name of the generated XML element to differ from the member's identifier.

You can set the same ElementName value to more than one class member if the generated XML document uses XML namespaces to distinguish between the identically named members. For details on how to use namespaces and prefixed names in the XML document, see the XmlSerializerNamespaces class.

The following example sets the ElementName property of an XmlElementAttribute to a new value.

' This is the class that will be serialized.
Public Class XClass
   ' The XML element name will be XName
   ' instead of the default ClassName.
   <XmlElement(ElementName := "XName")> Public ClassName() As String
End Class

// This is the class that will be serialized.
public class XClass
{
    /* The XML element name will be XName
       instead of the default ClassName. */
    /** @attribute XmlElement(ElementName = "XName")
     */
    public String className;
} //XClass

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft