XML DOM 문서 요소 속성
❮ 문서 객체
예시
다음 코드 조각은 " books.xml "을 xmlDoc에 로드하고 XML 문서의 위치를 표시합니다.
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;
var x =
xmlDoc.documentElement;
document.getElementById("demo").innerHTML
=
"Nodename: " + x.nodeName + "<br>" +
"Nodevalue: " + x.nodeValue + "<br>" +
"Nodetype: " +
x.nodeType;
}
산출:
Nodename: bookstore
Nodevalue: null
Nodetype: 1
정의 및 사용
documentElement 속성은 문서의 루트 노드를 반환합니다.
통사론
documentObject.documentElement
❮ 문서 객체