THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

XML DOM isEqualNode() Method


Node Object Reference Node 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 tests whether two nodes are equal.

Two nodes are equal when their names are the same, their attributes have the same name and value (does not have to be in the same order), and their child nodes are equal and in same order.

Tip: Use the isSameNode() method to determine if two nodes are the same node.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The isEqualNode() method is supported in all major browsers.

Note: Internet Explorer 9 and earlier do not support the isEqualNode() method.


Syntax

nodeObject.isEqualNode(nodetocheck)

Parameters

Parameter Type Description
nodetocheck Node object Required. The node to compare with the current node

Return Value

Type Description
Boolean true if the two nodes are equal, otherwise false

Technical Details

DOM Version Core Level 3 Node Object

Node Object Reference Node Object