XML DOM hasAttributes() 方法

定義和用法
hasAttributes() 方法在當前元素節點擁有屬性時返回 TRUE,否則返回 FALSE。
語法
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
