XML DOM removeAttributeNS() 메서드
정의와 사용법
removeAttributeNS()
이름 공간과 이름에 따라 지정된 속성을 제거하는 메서드.
문법
elementNode.removeAttributeNS(ns,name)
파라미터 | 설명 |
---|---|
ns | 必需. 제거할 속성의 이름 공간을 정의합니다. |
name | 必需. 제거할 속성 이름을 정의합니다. |
예제
아래 코드는 "books_ns.xml"을 xmlDoc에 로드하고 첫 번째 <title> 요소에서 "lang" 속성을 제거합니다:
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 = "속성 발견됨: " + x.hasAttributeNS(ns, "lang"); x.removeAttributeNS(ns, "lang"); document.getElementById("demo").innerHTML += "<br>속성 발견: " + x.hasAttributeNS(ns, "lang"); {}