XML DOM isEqualNode() Method
Definition and Usage
isEqualNode()
Method tests whether two nodes are equal.
If two nodes have the same name, attributes with the same names and values (the order is not required) and their child nodes are equal and in the same order, then the two nodes are equal.
Tip:Use the isSameNode() method to determine whether two nodes are the same node.
Syntax
nodeObject.isEqualNode(nodetocheck)
Parameters
Parameters | Description |
---|---|
nodetocheck | Required. Node object. The node to be compared with the current node. |
Technical Details
DOM Version: | Core Level 3 Node Object |
---|---|
Return value: | Boolean value. Returns true if the two nodes are equal, otherwise returns false. |
Example
The following code loads "books.xml" into xmlDoc and returns whether two nodes are equal:
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')[0]; var y = xmlDoc.getElementsByTagName('book')[2]; document.getElementById("demo").innerHTML = x.isEqualNode(y); }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
All mainstream browsers support isEqualNode()
Method.
Note: Internet Explorer 9 and earlier versions do not support this method.