XML DOM isEqualNode() method
Definition and usage
The isEqualNode() method returns true when the node is equal to a given node, otherwise it returns false.
Syntax:
nodeObject.isEqualNode(node)
Parameter | Description |
---|---|
node | Required. The node to be checked. |
Example
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
The following code can check if two nodes are equal:
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName("book")[1];
var y=xmlDoc.getElementsByTagName("book")[2];
document.write(x.isEqualNode(y)
);
Output:
false