XML DOM isSameNode() method
Definition and usage
The isSameNode() method returns true if the node is the same as the given node, otherwise it returns false.
Syntax:
nodeObject.isSameNode(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 checks if two nodes are the same node:
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName("book")[0];
var y=xmlDoc.getElementsByTagName("book")[1];
document.write(x.isSameNode(y)
);
Output:
false