XML DOM ownerDocument 속성
정의와 사용법
ownerDocument
속성은 요소의 뿌리 요소(문서 객체)를 반환합니다.
문법
attrObject.ownerDocument
예제
아래 코드는 "books.xml" 파일을 xmlDoc에 로드하고 첫 번째 category 속성 점의 뿌리 요소를 반환합니다:
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.getElementsByTagName('book'); document.getElementById("demo").innerHTML = x.item(0).attributes[0].ownerDocument + "<br>" + x.item(0).attributes[0].ownerDocument.nodeName + "<br>" + x.item(0).attributes[0].ownerDocument.nodeType; }