XML DOM ownerDocument 屬性
定義和用法
ownerDocument 屬性返回選定的元素所屬的文檔對(duì)象。
語(yǔ)法:
elementNode.ownerDocument
實(shí)例
在所有的例子中,我們將使用 XML 文件 books.xml,以及 JavaScript 函數(shù) loadXMLDoc()。
下面的代碼片段獲取 "books.xml" 中第一個(gè) <title> 元素的屬主文檔的名稱和節(jié)點(diǎn)類型:
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName("title")[0];
x=x.ownerDocument
;
document.write("Nodename: " + x.nodeName);
document.write(" (nodetype: " + x.nodeType + ")");
以上代碼的輸出:
Nodename: #document (nodetype: 9)