现在的位置: 首页 > 综合 > 正文

XML DOM ownerDocument 属性

2013年11月22日 ⁄ 综合 ⁄ 共 592字 ⁄ 字号 评论关闭
文章目录

XML DOM ownerDocument 属性

Attr 对象参考手册

定义和用法

ownerDocument 属性返回节点所属的根元素(Document 对象)。

语法:

attrObject.ownerDocument

实例

在所有的例子中,我们将使用 XML 文件 books.xml,以及 JavaScript 函数 loadXMLDoc()。

下面的代码片段返回 XML 文档中第一个 category 属性节点的根元素:

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

TIY

ownerDocument - 获取属性节点所属的根元素(document 对象)

Attr 对象参考手册

抱歉!评论已关闭.