XML DOM getAttributeNode()メソッド
Element オブジェクト
定義と使い方
getAttributeNode() メソッドは、現在の要素から名前によって属性ノードを取得します。
構文
elementNode.getAttributeNode(name)
| パラメータ | 説明 |
|---|---|
| name | 必須。取得する属性ノードを指定します。 |
例
以下のコードスニペットでは、loadXMLDoc()「」を xmlDoc に読み込み、すべての <book> 要素から "category" 属性を取得します:
例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
attnode=x.item(i).getAttributeNode("category");
document.write(attnode.name);
document.write(" = ");
document.write(attnode.value);
document.write("<br>");
}
出力:
category = COOKING
category = CHILDREN
category = WEB
category = WEB
category = CHILDREN
category = WEB
category = WEB
試してみる »
Element オブジェクト その他の拡張