X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

XML DOM isSameNode() Method


Node Object Reference Node Object

Definition and Usage

The isSameNode() method tests whether two nodes are the same node.

Tip: Use the isEqualNode() method to determine if two nodes are equal.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

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

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


Syntax

nodeObject.isSameNode(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 the same, otherwise false

Technical Details

DOM Version Core Level 3 Node Object


Example

The following code fragment loads "books.xml" into xmlDoc using loadXMLDoc() and tests whether the two nodes are the same node:

Example

xmlDoc = loadXMLDoc("books.xml");

x = xmlDoc.getElementsByTagName("book")[1];
y = xmlDoc.getElementsByTagName("book")[1];

document.write(x.isSameNode(y));

Output:

true

Try it yourself »

Node Object Reference Node Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook