Freigeben über


XmlAttribute.OwnerDocument Eigenschaft

Definition

Ruft das XmlDocument ab, zu dem dieser Knoten gehört.

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

Eigenschaftswert

Ein XML-Dokument, zu dem dieser Knoten gehört.

Beispiele

Im folgenden Beispiel wird ein Attribut erstellt und dessen OwnerDocumentangezeigt.

#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

Gilt für: