XML DOM removeAttributeNS() Method
Definition and Usage
removeAttributeNS()
Method to remove an attribute specified by namespace and name.
Syntax
elementNode.removeAttributeNS(ns,name)
Parameters | 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 loads "books_ns.xml" into xmlDoc and removes the "lang" attribute from the first <title> element:
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); {} }; xhttp.open("GET", "books_ns.xml", true); xhttp.send(); function myFunction(xml) { var xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName("title")[0]; var ns = "https://www.codew3c.com/meishi/"; document.getElementById("demo").innerHTML = "Attribute Found: " + x.hasAttributeNS(ns, "lang"); x.removeAttributeNS(ns, "lang"); document.getElementById("demo").innerHTML += "<br>Attribute Found: " + x.hasAttributeNS(ns, "lang"); {}