XmlDocumentFragment.OwnerDocument 속성

정의

이 노드가 속한 XmlDocument를 가져옵니다.

public:
 virtual property System::Xml::XmlDocument ^ OwnerDocument { System::Xml::XmlDocument ^ get(); };
public override System.Xml.XmlDocument OwnerDocument { get; }
member this.OwnerDocument : System.Xml.XmlDocument
Public Overrides ReadOnly Property OwnerDocument As XmlDocument

속성 값

XmlDocument

이 노드가 속한 XmlDocument입니다.

예제

다음 예제에서는 문서 조각에 새 노드를 추가합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   // Create the XmlDocument.
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<items/>" );
   
   // Create a document fragment.
   XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment();
   
   // Display the owner document of the document fragment.
   Console::WriteLine( docFrag->OwnerDocument->OuterXml );
   
   // Add nodes to the document fragment. Notice that the
   // new element is created using the owner document of 
   // the document fragment.
   XmlElement^ elem = doc->CreateElement( "item" );
   elem->InnerText = "widget";
   docFrag->AppendChild( elem );
   Console::WriteLine( "Display the document fragment..." );
   Console::WriteLine( docFrag->OuterXml );
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    // Create the XmlDocument.
    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<items/>");

    // Create a document fragment.
    XmlDocumentFragment docFrag = doc.CreateDocumentFragment();

    // Display the owner document of the document fragment.
    Console.WriteLine(docFrag.OwnerDocument.OuterXml);

    // Add nodes to the document fragment. Notice that the
    // new element is created using the owner document of
    // the document fragment.
    XmlElement elem = doc.CreateElement("item");
    elem.InnerText = "widget";
    docFrag.AppendChild(elem);

    Console.WriteLine("Display the document fragment...");
    Console.WriteLine(docFrag.OuterXml);
  }
}
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        ' Create the XmlDocument.
        Dim doc As New XmlDocument()
        doc.LoadXml("<items/>")
        
        ' Create a document fragment.
        Dim docFrag As XmlDocumentFragment = doc.CreateDocumentFragment()
        
        ' Display the owner document of the document fragment.
        Console.WriteLine(docFrag.OwnerDocument.OuterXml)
        
        ' Add nodes to the document fragment. Notice that the
        ' new element is created using the owner document of 
        ' the document fragment.
        Dim elem As XmlElement = doc.CreateElement("item")
        elem.InnerText = "widget"
        docFrag.AppendChild(elem)
        
        Console.WriteLine("Display the document fragment...")
        Console.WriteLine(docFrag.OuterXml)
    End Sub
End Class

설명

현재 노드가 노드를 추가 하는 경우 사용 합니다 XmlDocument 반환한는 OwnerDocument 속성 노드를 만듭니다.

적용 대상