XML DOM name 屬性
Attr 對象
定義和用法
name 屬性返回屬性的名稱。
語法
實例
下面的代碼片段使用 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("
");
}
輸出:
category = COOKING
category = CHILDREN
category = WEB
category = WEB
嘗試一下 ?
Attr 對象
更多建議: