XML DOM ownerDocument attribute
Definition and usage
ownerDocument can return the root element of an element.
Syntax:
nodeObject.ownerDocument
instance
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
The following code snippet can get the root element of the first <title> node in the XML document:
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName("title")[0].ownerDocument
;
document.write("Nodename: " + x.nodeName);
document.write(" (nodetype: " + x.nodeType + ")");
Output:
Nodename: #document (nodetype: 9)