XML DOM hasAttributes() روش
تعریف و استفاده
اگر گره فعلی هرگونه ویژگی دارد، hasAttributes()
این روش true را برمیگرداند، در غیر این صورت false را برمیگرداند.
زبان
hasAttributes()
مثال
زیرینکود "books.xml" را به xmlDoc بارگذاری میکند و بررسی میکند که آیا اولین علامت <book> هرگونه ویژگی دارد یا خیر:
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.hasAttributes(); }