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
