XML DOM isSameNode() Method
Definition and Usage
The isSameNode() method checks whether the specified node is the same as the existing node.
If two nodes are the same, this method returns true, otherwise it returns false.
Syntax:
elementNode.isSameNode(node)
Parameter | Description |
---|---|
node | Required. The node to be checked. |
Example
In all examples, we will use the XML file books.xml, as well as the JavaScript function loadXMLDoc().
The following node checks whether two nodes are the same:
xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName("book")[0]; y=xmlDoc.getElementsByTagName("book")[1]; document.write(x.isSameNode(y));
The output of the above code is:
false