Przeczytaj w języku angielskim

Udostępnij za pośrednictwem


XObject.Document Właściwość

Definicja

Pobiera element XDocument dla tego pliku XObject.

public System.Xml.Linq.XDocument Document { get; }
public System.Xml.Linq.XDocument? Document { get; }

Wartość właściwości

XDocument

Element XDocument dla tego XObject.

Przykłady

Poniższy przykład tworzy dokument z złożoną zawartością. Następnie używa tej właściwości do pobrania dokumentu dla Child elementu.

XDocument doc = new XDocument(  
    new XComment("A comment in the document."),  
    new XElement("Root",  
        new XElement("Child", "content")  
    )  
);  
XElement child = doc.Descendants("Child").First();  
XDocument documentOfChild = child.Document;  
Console.WriteLine(documentOfChild.FirstNode);  

Ten przykład generuje następujące wyniki:

<!--A comment in the document.-->  

Dotyczy

Zobacz też