XML DOM nodeValue 속성

정의와 사용법

nodeValue 속성을 설정하거나 반환하며, 노드의 타입에 따라 다릅니다.

문법

nodeObject.nodeValue

예제

아래 코드는 "books.xml" 파일을 xmlDoc에 로드하고, 루트 노드의 노드 이름과 노드 값을 표시합니다:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   }
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    document.getElementById("demo").innerHTML =
    "Nodename: " + xmlDoc.nodeName +
    (" (value: " + xmlDoc.childNodes[0].nodeValue) + ")";
}

직접 시도해 보세요