XmlElementAttribute.ElementName 속성

정의

생성된 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

속성 값

생성된 XML 요소의 이름입니다. 기본값은 멤버 식별자입니다.

예제

다음 예제에서는 의 ElementNameXmlElementAttribute 속성을 새 값으로 설정합니다.

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

설명

ElementName 생성된 XML 요소의 이름이 멤버의 식별자와 달라지도록 하려면 를 지정합니다.

생성된 XML 문서에서 XML 네임스페이스를 사용하여 이름이 동일한 멤버를 구분하는 경우 동일한 ElementName 값을 둘 이상의 클래스 멤버로 설정할 수 있습니다. XML 문서에서 네임스페이스 및 접두사 이름을 사용하는 방법에 대한 자세한 내용은 클래스를 XmlSerializerNamespaces 참조하세요.

적용 대상

추가 정보