XmlArrayItemAttribute.ElementName 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
생성된 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 요소의 이름입니다. 기본값은 멤버 식별자입니다.
예제
다음 예제에서는 클래스 및 Car 클래스의 Vehicle 속성을 설정 ElementName 하여 해당 클래스에 대해 생성하는 XML 요소 XmlSerializer 의 이름을 변경합니다.
public class Transportation
{
[XmlArray("Vehicles")]
/* Specifies acceptable types and the ElementName generated
for each object type. */
[XmlArrayItem(typeof(Vehicle), ElementName = "Transport"),
XmlArrayItem(typeof(Car), ElementName = "Automobile")]
public Vehicle[] MyVehicles;
}
// By default, this class results in XML elements named "Vehicle".
public class Vehicle
{
public string id;
}
// By default, this class results in XML elements named "Car".
public class Car:Vehicle
{
public string Maker;
}
Public Class Transportation
' Specifies acceptable types and the ElementName generated
' for each object type.
<XmlArray("Vehicles"), _
XmlArrayItem(GetType(Vehicle), ElementName := "Transport"), _
XmlArrayItem(GetType(Car), ElementName := "Automobile")> _
Public MyVehicles() As Vehicle
End Class
' By default, this class results in XML elements named "Vehicle".
Public Class Vehicle
Public id As String
End Class
' By default, this class results in XMl elements named "Car".
Public Class Car
Inherits Vehicle
Public Maker As String
End Class
설명
ElementName 생성된 XML 요소의 이름이 멤버의 식별자와 다를지 지정합니다.
생성된 XML 문서에서 XML 네임스페이스를 사용하여 이름이 동일한 멤버를 구분하는 경우 동일한 ElementName 값을 둘 이상의 클래스 멤버로 설정할 수 있습니다. XML 문서에서 네임스페이스 및 접두사 이름을 사용하는 방법에 대한 자세한 내용은 클래스를 XmlSerializerNamespaces 참조하세요.