XML DOM isSameNode() 메서드
❮ 노드 객체
예시
다음 코드 조각은 " 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;
var x =
xmlDoc.getElementsByTagName('book')[1];
var y =
xmlDoc.getElementsByTagName('book')[1];
document.getElementById("demo").innerHTML =
x.isSameNode(y);
}
산출:
true
정의 및 사용
isSameNode() 메서드는 두 노드가 동일한 노드인지 테스트합니다.
팁: isEqualNode() 메서드를 사용하여 두 노드가 동일한지 확인합니다.
브라우저 지원
isSameNode() 메서드는 모든 주요 브라우저에서 지원됩니다.
참고: Internet Explorer 9 및 이전 버전은 isSameNode() 메서드를 지원하지 않습니다.
통사론
nodeObject.isSameNode(nodetocheck)
매개변수
Parameter | Type | Description |
---|---|---|
nodetocheck | Node object | Required. The node to compare with the current node |
반환 값
Type | Description |
---|---|
Boolean | true if the two nodes are the same, otherwise false |
기술적 세부 사항
DOM 버전 | 코어 레벨 3 노드 객체 |
---|
❮ 노드 객체