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.cnn84.com/school/w3c/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
系统帮助 | 给我留言 | 收藏本站
Copyright © 2005-2008 www.cnn84.com All Rights Reserved Ver:2.0
CNN84网是公益性便民网站,是为了给大家的日常生活查询及提供最快捷的出行指南