XML DOM nodeType 屬性
Attr 對(duì)象
定義和用法
nodeType 屬性返回節(jié)點(diǎn)的類(lèi)型。
語(yǔ)法
實(shí)例
下面的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,并顯示 category 屬性的節(jié)點(diǎn)名稱(chēng)、節(jié)點(diǎn)值和節(jié)點(diǎn)類(lèi)型:
實(shí)例
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 對(duì)象
更多建議: