Прочетете на английски Редактиране

Споделяне чрез


XmlAttribute.OwnerDocument Property

Definition

Gets the XmlDocument to which this node belongs.

C#
public override System.Xml.XmlDocument OwnerDocument { get; }

Property Value

An XML document to which this node belongs.

Examples

The following example creates an attribute and displays its OwnerDocument.

C#
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);
   }
}

Applies to

Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0