XmlAttribute.OwnerDocument Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the XmlDocument to which this node belongs.
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
Property Value
An XML document to which this node belongs.
Examples
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 );
}
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
Applies to
Werk met ons samen op GitHub
De bron voor deze inhoud vindt u op GitHub, waar u ook problemen en pull-aanvragen kunt maken en bekijken. Raadpleeg onze gids voor inzenders voor meer informatie.