XObject.Parent 속성

정의

XElement항목의 부모를 XObject 가져옵니다.

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

속성 값

XElement부모 XObject 입니다.

예제

다음 예제에서는 이 메서드를 사용합니다.

XDocument doc = new XDocument(
    new XComment("A comment in the document."),
    new XElement("Root",
        new XElement("Child", "content")
    )
);
XElement child = doc.Descendants("Child").First();
XElement root = child.Parent;
Console.WriteLine(root.Name);
Dim doc As XDocument = _
    <?xml version="1.0"?>
    <!--A comment in the document.-->
    <Root>
        <Child>content</Child>
    </Root>
Dim child As XElement = doc.Descendants("Child").First()
Dim root As XElement = child.Parent
Console.WriteLine(root.Name)

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

Root

설명

XObject 부모 요소가 없으면 이 속성이 반환됩니다null.

메모

이 속성은 부모 요소를 반환하고, 부모 요소가 없는 자식 노드의 XDocument 경우 이 속성이 해당 요소를 반환 null 합니다.

적용 대상

추가 정보