XML DOM ownerDocumentProperty


Attr object

Definition and Usage

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

Syntax

attrObject.ownerDocument


Example

The following code snippet usesloadXMLDoc()put "books.xmlLoads 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

Try it Yourself »

Attr objectother extensions