Returns the root of the document that contains the node.
var objXMLDOMDocument = oXMLDOMNode.ownerDocument;
The following script example uses the ownerDocument property to return the parent DOMDocument object, and then displays that object's root element tag name.
var xmlDoc = new ActiveXObject5.0("Msxml2.DOMDocument.5.0");
var currNode;
var owner;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
var myErr = xmlDoc.parseError;
alert("You have error " + myErr.reason);
} else {
currNode = xmlDoc.documentElement.childNodes.item(0).childNodes.item(1);
owner = currNode.ownerDocument;
alert(owner.documentElement.tagName);
}
Set objXMLDOMDocument = oXMLDOMNode.ownerDocument
The following Microsoft® Visual Basic® example uses the ownerDocument property to return the parent DOMDocument object, and then displays that object's root element tag name.
Dim xmlDoc As New Msxml2.DOMDocument50
Dim currNode As IXMLDOMNode
Dim owner As DOMDocument50
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
Set currNode = xmlDoc.documentElement.childNodes.Item(0).childNodes.Item(1)
Set owner = currNode.ownerDocument
MsgBox owner.documentElement.tagName
End If
HRESULT get_ownerDocument(
IXMLDOMDocument **DOMDocument);
DOMDocument parameter is Null.The property is read-only. It returns the parent document that represents the root of the document to which this node belongs.
All nodes are created in the context of a document, and the ownerDocument property is maintained until the node is added to another document. For a node removed from a document, this property indicates the document in which the node was last included.
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
Applies to: IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText