XML DOM isSameNode() Metode
❮ Node Voorwerp
Voorbeeld
Die volgende kodefragment laai " books.xml " in xmlDoc en toets of die twee nodusse dieselfde nodus is:
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')[1];
var y =
xmlDoc.getElementsByTagName('book')[1];
document.getElementById("demo").innerHTML =
x.isSameNode(y);
}
Uitset:
true
Definisie en gebruik
Die isSameNode() metode toets of twee nodusse dieselfde nodus is.
Wenk: Gebruik die isEqualNode() metode om te bepaal of twee nodusse gelyk is.
Blaaierondersteuning
Die isSameNode() metode word in alle groot blaaiers ondersteun.
Let wel: Internet Explorer 9 en vroeër ondersteun nie die isSameNode() metode nie.
Sintaksis
nodeObject.isSameNode(nodetocheck)
Grense
Parameter | Type | Description |
---|---|---|
nodetocheck | Node object | Required. The node to compare with the current node |
Terugkeerwaarde
Type | Description |
---|---|
Boolean | true if the two nodes are the same, otherwise false |
Tegniese besonderhede
DOM weergawe | Kernvlak 3 Node-objek |
---|
❮ Node Voorwerp