XML DOM ownerElement 属性

定义和用法

ownerElement 属性返回 attribute 所附属的元素节点。

语法:

attrObject.ownerElement

实例

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

下面的代码片段返回第一个 category 属性所附属的元素:

xmlDoc=loadXMLDoc("/example/xdom/books.xml");

x=xmlDoc.getElementsByTagName('book');

document.write(x.item(0).attributes[0].ownerElement);
document.write("<br />");
document.write(x.item(0).attributes[0].ownerElement.nodeName);
document.write("<br />");
document.write(x.item(0).attributes[0].ownerElement.nodeType);

以上代码的输出:

[object Element]
book
1
系统帮助 | 给我留言 | 收藏本站
Copyright © 2005-2008 www.cnn84.com All Rights Reserved Ver:2.0
CNN84网是公益性便民网站,是为了给大家的日常生活查询及提供最快捷的出行指南