Método removeAttributeNS() do XML DOM

Definição e Uso

removeAttributeNS() Método remove o atributo especificado pelo espaço de nomes e nome.

Sintaxe

elementNode.removeAttributeNS(ns,name)
Parâmetros Descrição
ns Obrigatório. Especifica o espaço de nomes do atributo a ser removido.
name Obrigatório. Especifica o nome do atributo a ser removido.

Exemplo

O código a seguir carrega "books_ns.xml" para xmlDoc e remove o atributo "lang" do primeiro elemento <title>:

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 =
    "Atributo Encontrado: " + x.hasAttributeNS(ns, "lang");
    x.removeAttributeNS(ns, "lang");
    document.getElementById("demo").innerHTML +=
    "<br>Atributo Encontrado: " + x.hasAttributeNS(ns, "lang");
}

Experimente por Si Mesmo