XML DOM removeAttributeNS()Methods
Element object
Definition and Usage
The removeAttributeNS() method removes an attribute specified by namespace and name.
Syntax
elementNode.removeAttributeNS(ns,name)
| Parameter | Description |
|---|---|
| ns | Required. Specifies the namespace of the attribute to be removed. |
| name | Required. Specifies the name of the attribute to be removed. |
Example
The following code snippet usesloadXMLDoc()put "books_ns.xmlLoad into xmlDoc, and delete the "lang" attribute of the first <title> element:
Example
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];
ns="http://www.example.com/w3cnote/";
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"));
Output:
Attribute Found: true
Attribute Found: false
Attribute Found: false
Try it Yourself »
Element objectother extensions