XML DOM isSameNode() Method
Definition and Usage
isSameNode()
The method tests whether two nodes are the same node.
Tip:Use the isEqualNode() method to determine whether two nodes are equal.
Syntax
nodeObject.isSameNode(nodetocheck)
Parameters
Parameters | Description |
---|---|
nodetocheck | Required. Node object. The node to be compared with the current node. |
Technical Details
Return value: | Boolean value. Returns true if two nodes are the same, otherwise false. |
---|---|
DOM Version: | Core Level 3 Node Object |
Example
The following code loads "books.xml" into xmlDoc and tests whether two nodes are the same node:
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); }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
All mainstream browsers support isSameNode()
Method.
Note: Internet Explorer 9 and earlier versions do not support this method.