XML DOM hasAttributes() 方法

定义和用法
hasAttributes() 方法在节点拥有属性时返回 true,否则返回 false。
语法
nodeObject.hasAttributes()
实例
下面的代码片段使用 loadXMLDoc() 把 "books.xml" 载入 xmlDoc 中,并返回第一个 <book> 元素是否拥有属性:
实例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes());
x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes());
输出:
true
