Easy Tutorial
❮ Dom Nodetype Prop Document Firstchild ❯

XML DOM ownerDocument Property



Definition and Usage

The ownerDocument property returns the root element (document object) to which the node belongs.

Syntax


Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and returns the root element of the first category attribute node:

Example

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

document.write(x.item(0).attributes[0].ownerDocument);
document.write("<br>");
document.write(x.item(0).attributes[0].ownerDocument.nodeName);
document.write("<br>");
document.write(x.item(0).attributes[0].ownerDocument.nodeType);

The above code will output:

[object XMLDocument]
#document
9

❮ Dom Nodetype Prop Document Firstchild ❯