XmlElementAttribute.ElementName Właściwość

Definicja

Pobiera lub ustawia nazwę wygenerowanego elementu XML.

public:
 property System::String ^ ElementName { System::String ^ get(); void set(System::String ^ value); };
public string ElementName { get; set; }
member this.ElementName : string with get, set
Public Property ElementName As String

Wartość właściwości

Nazwa wygenerowanego elementu XML. Wartość domyślna to identyfikator elementu członkowskiego.

Przykłady

Poniższy przykład ustawia ElementName właściwość elementu XmlElementAttribute na nową wartość.

// 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;
};
// 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.
   <XmlElement(ElementName := "XName")> Public ClassName() As String
End Class

Uwagi

Określ, ElementName czy chcesz, aby nazwa wygenerowanego elementu XML różniła się od identyfikatora elementu członkowskiego.

Możesz ustawić tę samą ElementName wartość na więcej niż jeden element członkowski klasy, jeśli wygenerowany dokument XML używa przestrzeni nazw XML do odróżnienia identycznych nazwanych elementów członkowskich. Aby uzyskać szczegółowe informacje na temat używania przestrzeni nazw i prefiksów nazw w dokumencie XML, zobacz klasę XmlSerializerNamespaces .

Dotyczy

Zobacz też