XML DOM ownerElement 속성

정의와 사용법

ownerElement 속성은 속성이 부착된 요소 노드를 반환합니다.

문법

attrObject.ownerElement

예제

아래 코드는 "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].ownerElement + "<br>" +
    x.item(0).attributes[0].ownerElement .nodeName + "<br>" +
    x.item(0).attributes[0].ownerElement .nodeType;
}

직접 시험해 보세요