XML DOM removeAttributeNode() メソッド
Element オブジェクト
定義と用法
removeAttributeNode() メソッドは、指定した属性を削除します。
DTD に属性のデフォルト値が定義されている場合、デフォルト値を持つ新しい属性が直ちに現れます。
This function returns the removed attribute node.
構文
elementNode.removeAttributeNode(node)
|
例
次のコードは、loadXMLDoc() を使用して xmlDoc に
"books.xml" をロードし、
全 <book> 要素から "category" 属性ノードを削除します:
例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
attnode=x.item(i).getAttributeNode("category");
old_att=x.item(i).removeAttributeNode(attnode);
document.write("Removed attribute: " + old_att.name + "<br />");
}
|
出力:
Removed attribute: category
Removed attribute: category
Removed attribute: category
Removed attribute: category
|
試してください »
|
Element オブジェクト
|