XmlAttribute.OwnerDocument Propriété

Définition

Obtient le XmlDocument auquel ce nœud appartient.

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

Valeur de propriété

XmlDocument

Un document XML auquel ce nœud appartient.

Exemples

L’exemple suivant crée un attribut et affiche son 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 );
}
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);
   }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>") 

    'Create an attribute.
    Dim attr as XmlAttribute
    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)

  end sub
end class

S’applique à