Attr 对象
定义和用法
nodeType 属性返回节点的类型。
语法
attrObject.nodeType
实例
实例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].nodeName);
document.write(" = ");
document.write(x.item(i).attributes[0].nodeValue);
document.write(" (nodetype: " + x.item(i).attributes[0].nodeType + ")");
document.write("<br>");
}
输出:
category = COOKING (nodetype: 2)
category = CHILDREN (nodetype: 2)
category = WEB (nodetype: 2)
category = WEB (nodetype: 2)
category = CHILDREN (nodetype: 2)
category = WEB (nodetype: 2)
category = WEB (nodetype: 2)
Attr 对象其他扩展