TUTORIAL前端与浏览器FETCHED
XML DOM ownerDocument 属性
XML DOM ownerDocument 属性 Attr 对象 定义和用法 ownerDocument 属性返回节点所属的根元素(document 对象)。 语法 attrObject.ownerDocument 实例 下面的代码片段使用 loadXMLDoc() 把 'books.xml' 载入 xmlDoc 中,并返回第一个 category 属性节点的根元素: 实例 [mycode3 typ..
更新于 2026/7/16
教程详情页默认 noindex。
XML DOM ownerDocument 属性
Attr 对象
定义和用法
ownerDocument 属性返回节点所属的根元素(document 对象)。
语法
attrObject.ownerDocument
实例
下面的代码片段使用 loadXMLDoc() 把 "books.xml" 载入 xmlDoc 中,并返回第一个 category 属性节点的根元素:
实例
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);
上面的代码将输出:
[object XMLDocument]
#document
9
#document
9
尝试一下 »
Attr 对象