다음을 통해 공유


XmlElementAttribute.ElementName 속성

생성된 XML 요소의 이름을 가져오거나 설정합니다.

네임스페이스: System.Xml.Serialization
어셈블리: System.Xml(system.xml.dll)

구문

‘선언
Public Property ElementName As String
‘사용 방법
Dim instance As XmlElementAttribute
Dim value As String

value = instance.ElementName

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

/** @property */
public void set_ElementName (String value)
public function get ElementName () : String

public function set ElementName (value : String)

속성 값

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

설명

생성된 XML 요소 이름을 멤버 식별자와 다르게 하려면 ElementName을 지정합니다.

생성된 XML 문서가 네임스페이스를 사용하여 이름이 같은 멤버 간을 구별하는 경우 여러 클래스 멤버에 동일한 ElementName 값을 설정할 수 있습니다. XML 문서에서 네임스페이스 및 접두사가 붙은 이름을 사용하는 방법에 대한 자세한 내용은 XmlSerializerNamespaces 클래스를 참조하십시오.

예제

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

' 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. */
   [XmlElement(ElementName = "XName")]
   public string ClassName;
} 
// 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. */
    /** @attribute XmlElement(ElementName = "XName")
     */
    public String className;
} //XClass

플랫폼

Windows 98, Windows 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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

XmlElementAttribute 클래스
XmlElementAttribute 멤버
System.Xml.Serialization 네임스페이스
XmlAttributeAttribute.AttributeName 속성