Proprietà XmlElementAttribute.ElementName (System.Xml.Serialization)

Cambia visualizzazione:
ScriptFree
Riferimento a .NET Framework
Proprietà XmlElementAttribute.ElementName

Ottiene o imposta il nome dell'elemento XML generato.

Spazio dei nomi: System.Xml.Serialization
Assembly: System.Xml (in system.xml.dll)

Sintassi

Visual Basic - (Dichiarazione)
Public Property ElementName As String
Visual Basic (Utilizzo)
Dim instance As XmlElementAttribute
Dim value As String

value = instance.ElementName

instance.ElementName = value
C#
public string ElementName { get; set; }
C++
public:
property String^ ElementName {
	String^ get ();
	void set (String^ value);
}
J#
/** @property */
public String get_ElementName ()

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

JScript
public function get ElementName () : String

public function set ElementName (value : String)

Valore proprietà

Il nome dell'elemento XML generato. Il valore predefinito è l'identificatore del membro.
Note

Specificare un ElementName se si desidera che il nome dell'elemento XML generato sia diverso dall'identificatore del membro.

È possibile impostare lo stesso valore ElementName su più di un membro di classe a condizione che il documento XML generato utilizzi gli spazi dei nomi XML per distinguere tra membri con nome uguale. Per ulteriori dettagli sull'utilizzo degli spazi dei nomi e dei nomi con prefisso nel documento XML, vedere la classe XmlSerializerNamespaces.

Esempio

Nell'esempio seguente viene impostata la proprietà ElementName di un XmlElementAttribute su un nuovo valore.

Visual Basic
' 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

C#
// 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;
} 

C++
// This is the class that will be serialized.
public ref class XClass
{
public:
   /* The XML element name will be XName
   instead of the default ClassName. */
   [XmlElement(ElementName="XName")]
   String^ ClassName;
};

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

Piattaforme

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

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.

Informazioni sulla versione

.NET Framework

Supportato in: 2.0 1.1 1.0

.NET Compact Framework

Supportato in: 2.0 1.0
Vedere anche