XML DOM isSameNode()メソッド
❮ノードオブジェクト
例
次のコードフラグメントは、「books.xml」をxmlDocにロードし、2つのノードが同じノードであるかどうかをテストします。
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()メソッドは、2つのノードが同じノードであるかどうかをテストします。
ヒント:isEqualNode()メソッドを使用して 、2つのノードが等しいかどうかを判別します。
ブラウザのサポート
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ノードオブジェクト |
---|
❮ノードオブジェクト