XML DOM isEqualNode() Method


❮ 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 (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);
}

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
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.