XmlAttribute.OwnerDocument Property

 
System_CAPS_noteNote

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)

public override XmlDocument OwnerDocument { get; }

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;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main(){

    XmlDocument doc = new 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
Show: