XAttribute.Name 속성

정의

이 특성의 확장된 이름을 가져옵니다.

public:
 property System::Xml::Linq::XName ^ Name { System::Xml::Linq::XName ^ get(); };
public System.Xml.Linq.XName Name { get; }
member this.Name : System.Xml.Linq.XName
Public ReadOnly Property Name As XName

속성 값

XName

이 특성의 이름이 들어 있는 XName입니다.

예제

다음 예제에서는 세 가지 특성이 있는 요소를 만듭니다. 그런 다음 이 속성을 사용하여 각 특성의 이름을 출력합니다. 또한 이 예제에서는 기존 특성의 이름을 사용하여 새 특성을 만드는 방법을 보여 있습니다.

XNamespace aw = "http://www.adventure-works.com";  
XElement root = new XElement(aw + "Root",  
    new XAttribute(XNamespace.Xmlns + "aw", "http://www.adventure-works.com"),  
    new XAttribute(aw + "Att", "content"),  
    new XAttribute("Att2", "different content")  
);  

foreach (XAttribute att in root.Attributes())  
    Console.WriteLine("{0}={1}", att.Name, att.Value);  
Console.WriteLine("");  

XElement newRoot = new XElement(aw + "Root",  
    from att in root.Attributes("Att2")  
    select new XAttribute(att.Name, "new content"));  

foreach (XAttribute att in newRoot.Attributes())  
    Console.WriteLine("{0}={1}", att.Name, att.Value);  
Dim root As XElement = _   
    <aw:Root xmlns:aw='http://www.adventure-works.com'  
        aw:Att='content'  
        Att2='different content'/>  

For Each att As XAttribute In root.Attributes()  
    Console.WriteLine("{0}={1}", att.Name, att.Value)  
Next  
Console.WriteLine("")  

Dim NewRoot As XElement = _  
<Root  
    <%= _  
        From att In root.Attributes("Att2") _  
        Select New XAttribute(att.Name, "new content") _  
    %>>_  
</Root>  

For Each att As XAttribute In NewRoot.Attributes()  
    Console.WriteLine("{0}={1}", att.Name, att.Value)  
Next  

이 예제는 다음과 같은 출력을 생성합니다.

{http://www.w3.org/2000/xmlns/}aw=http://www.adventure-works.com  
{http://www.adventure-works.com}Att=content  
Att2=different content  

Att2=new content  

설명

이 속성에서 반환된 확장된 이름은 형식 {namespace}localname입니다.

적용 대상

추가 정보