XML DOM name 属性
定義と用法
name 属性は属性の名前を返します。
文法:
attrObject.name
インスタンス
すべての例では、以下の XML ファイルを使用します books.xml、および JavaScript 関数 loadXMLDoc()。
以下のコードスニペットは category 属性の名前と値を表示しています:
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
var 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 = children category = cooking category = web category = web