XML DOM getAttributeNode() 方法


Element 对象参考手册 Element 对象

定义和用法

getAttributeNode() 方法从当前元素中通过名称取得属性节点。

语法

elementNode.getAttributeNode(name)
参数 描述
name 必需。规定要获取的属性节点。

实例

实例

xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName('book'); for(i=0;i<x.length;i++) { attnode=x.item(i).getAttributeNode("category"); document.write(attnode.name); document.write(" = "); document.write(attnode.value); document.write("<br>"); }

输出:

category = COOKING
category = CHILDREN
category = WEB
category = WEB

运行代码 »

Element 对象参考手册 Element 对象其他扩展