XObject.Parent Özellik

Tanım

Bu XElementöğesinin üst öğesini XObject alır.

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

Özellik Değeri

Bu XElementöğesinin üst öğesiXObject.

Örnekler

Aşağıdaki örnek bu yöntemi kullanır.

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)

Bu örnek aşağıdaki çıkışı oluşturur:

Root

Açıklamalar

Bunun XObject üst öğesi yoksa, bu özellik döndürür null.

Note

Bu özellik üst öğeyi döndürür ve alt XDocument düğümlerinin üst öğesi olmadığından, bu özellik onlar için döndürür null .

Şunlara uygulanır

Ayrıca bkz.