XML DOM isEqualNode() Method

Definition and Usage

If the node is equal to the given node then isEqualNode() The method returns true if the node is equal to the given node, otherwise returns false.

Syntax

elementObject.isEqualNode(node)
Parameter Description
node Required. The node to be checked.

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);
{}

Try It Yourself