<html lang="ko">
<head>
<meta charset="UTF-8">
<title>XML Node</title>
<script>
function loadDoc() {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if(this.status == 200 && this.readyState == this.DONE) {
removeNode(xmlHttp);
}
};
xmlHttp.open("GET", "/examples/media/programming_languages.xml", true);
xmlHttp.send();
}
function removeNode(xmlHttp) {
var xmlObj, firstStandard, result;
xmlObj = xmlHttp.responseXML; // 요청한 데이터를 XML DOM 객체로 반환함.
firstStandard = xmlObj.getElementsByTagName("priority")[0]; // 첫 번째 <priority>요소를 반환함.
result = "변경 전 : ";
result += firstStandard.getAttribute("rating"); // rating 속성의 속성값을 출력함.
firstStandard.removeAttribute("rating"); // 첫 번째 <priority>요소의 rating 속성을 제거함.
result += "<br>변경 후 : " + firstStandard.getAttribute("rating"); // rating 속성의 속성값을 출력함.
document.getElementById("text").innerHTML = result;
}
</script>
</head>
<body>
<h1>노드의 제거</h1>
<button onclick="loadDoc()">속성 노드 제거!</button>
<p id="text"></p>
</body>
</html>