XML DOM 소유자 요소 속성
❮ 속성 개체
예시
다음 코드 조각은 " 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;
}
위 코드의 출력은 다음과 같습니다.
[object Element]
book
1
정의 및 사용
ownerElement 속성은 속성이 연결된 요소 노드를 반환합니다.
통사론
attrObject.ownerElement
❮ 속성 개체