XML DOM ownerDocument 屬性
Attr 對象
定義和用法
ownerDocument 屬性返回節(jié)點(diǎn)所屬的根元素(document 對象)。
語法
實(shí)例
下面的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,并返回第一個 category 屬性節(jié)點(diǎn)的根元素:
實(shí)例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
document.write(x.item(0).attributes[0].ownerDocument);
document.write("
");
document.write(x.item(0).attributes[0].ownerDocument.nodeName);
document.write("
");
document.write(x.item(0).attributes[0].ownerDocument.nodeType);
上面的代碼將輸出:
[object XMLDocument]
#document
9
嘗試一下 ?
Attr 對象
更多建議: