XML DOM nodeValue 屬性
Attr 對象
定義和用法
nodeValue 屬性設(shè)置或返回節(jié)點的值,根據(jù)其類型。
語法
實例
下面的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,并顯示 category 屬性的節(jié)點名稱、節(jié)點值和節(jié)點類型:
實例
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: ");
document.write(x.item(i).attributes[0].nodeType + ")");
document.write("
");
}
輸出:
category = COOKING (nodetype: 2)
category = CHILDREN (nodetype: 2)
category = WEB (nodetype: 2)
category = WEB (nodetype: 2)
嘗試一下 ?
Attr 對象
更多建議: