XML DOM value 屬性


Attr 對象參考手冊 Attr 對象

定義和用法

value 屬性返回屬性的值。

語法

attrObject.value


實例

下麵的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,並顯示 category 屬性的名稱和值:

實例

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

輸出:

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


Attr 對象參考手冊 Attr 對象