XML DOM hasChildNodes() Metodu
Tanım ve Kullanım
Eğer mevcut element node alt öğeleri varsa hasChildNodes()
Metod doğruysa true döner, aksi takdirde false döner.
Grady
elementNode.hasChildNodes()
Örnek
Aşağıdaki kod "books.xml" dosyasını xmlDoc'a yükler ve ilk <book> öğesinin herhangi bir alt öğesi olup olmadığını kontrol eder:
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]; document.getElementById("demo").innerHTML = x.hasChildNodes(); }