XmlAttribute::OwnerDocument Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the XmlDocument to which this node belongs.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

property XmlDocument^ OwnerDocument {
	virtual XmlDocument^ get() override;

Property Value

Type: System.Xml::XmlDocument^

An XML document to which this node belongs.

The following example creates an attribute and displays its OwnerDocument.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book><title>Pride And Prejudice</title></book>" );

   //Create an attribute.
   XmlAttribute^ attr;
   attr = doc->CreateAttribute( "bk", "genre", "urn:samples" );
   attr->Value = "novel";

   //Display the attribute's owner document. Note
   //that although the attribute has not been inserted
   //into the document, it still has an owner document.
   Console::WriteLine( attr->OwnerDocument->OuterXml );

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top