XML DOM ownerDocument 屬性
實(shí)例
在所有的例子中,我們將使用 XML 文件 books.xml,以及 JavaScript 函數(shù) loadXMLDoc()。
下面的代碼片段返回 XML 文檔中第一個(gè) category 屬性節(jié)點(diǎn)的根元素:
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
);
以上代碼的輸出:
[object XMLDocument] #document 9