XML DOM removeAttributeNS() メソッド

定義と用法

removeAttributeNS() メソッドは、命名空間と名前で指定された属性を削除します。

文法:

elementNode.removeAttributeNS(ns,name)
パラメータ 説明
ns 必須。削除する属性の名前空間を指定します。
name 必須。削除する属性の名前を指定します。

すべての例では、以下の XML ファイルを使用します: books_ns.xml、および JavaScript 関数 loadXMLDoc()

以下のコードスニペットは、"books_ns.xml" 内の最初の <title> 要素から "lang" 属性を削除します:

xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.codew3c.com/children/";
document.write("Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));
x.removeAttributeNS(ns,"lang");
document.write("<br />Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));

出力:

Attribute Found: true
Attribute Found: false