Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XmlElementAttribute.ElementName Property

Gets or sets the name of the generated XML element.

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

public string ElementName { get; set; }
/** @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 string ClassName;
} 

// 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

Show:
© 2014 Microsoft