XML DOM isEqualNode() Method
Definition and Usage
isEqualNode()
Method tests whether two nodes are equal.
If two nodes have the same name, attributes with the same names and values (not necessarily in the same order) and their child nodes are equal and in the same order, then the two nodes are equal.
Tip:Use the isSameNode() method to determine whether two nodes are the same node.
Syntax
nodeObject.isEqualNode(nodetocheck)
Parameters
Parameters | Description |
---|---|
nodetocheck | Required. Node object. The node to be compared with the current node. |
Technical Details
DOM Version: | Core Level 3 Node Object |
---|---|
Return value: | Boolean value. If two nodes are equal, it returns true, otherwise false. |
Example
Below code loads "books.xml" into xmlDoc and returns whether two nodes are equal:
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); } }; 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); }
Υποστήριξη Περιηγητών
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
Όλοι οι κύριοι περιηγητές υποστηρίζουν isEqualNode()
Μέθοδος.
Σημείωση: Οι εκδόσεις Internet Explorer 9 και παλιότερες δεν υποστηρίζουν αυτή τη μέθοδο.