XML DOM ownerDocument Attribute
Definition and Usage
The ownerDocument property returns the root element of the nodeDocument object).
Syntax:
attrObject.ownerDocument
Instance
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
The following code snippet returns the root element of the first category attribute node in the XML document:
xmlDoc=loadXMLDoc("/example/xdom/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 output of the above code is:
[object XMLDocument] #document 9