XML DOM removeAttributeNS () method
Definition and Usage
removeAttributeNS () method removes a specified by the namespace and name properties.
grammar
elementNode.removeAttributeNS(ns,name)
参数 | 描述 |
---|---|
ns | 必需。规定要删除的属性的命名空间。 |
name | 必需。规定要删除的属性的名称。 |
Examples
The following code fragment uses loadXMLDoc () to " books_ns.xml " into xmlDoc, and remove the first "lang" attribute <title> element:
Examples
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.w3schools.com/children/";
document.write("Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));
x.removeAttributeNS(ns,"lang");
document.write("
Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.w3schools.com/children/";
document.write("Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));
x.removeAttributeNS(ns,"lang");
document.write("
Attribute Found: ");
document.write(x.hasAttributeNS(ns,"lang"));
Output:
Attribute Found: true
Attribute Found: false
Attribute Found: false
try it"
Element object