THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

XML DOM isEqualNode() Method


Element Object Reference Element Object

Example

The following code fragment loads "books.xml" into xmlDoc and returns whether two nodes are equal:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
        myFunction(xhttp);
    }
};
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);
}

Output:

false
Try it Yourself »

Definition and Usage

The isEqualNode() method returns true if a node is equal to the given one, otherwise it returns false.

Syntax

elementObject.isEqualNode(node)

Parameter Description
node Required. The node to check

Element Object Reference Element Object