XML DOM nodeName एट्रिब्यूट
वर्णन और उपयोग
nodeName
एट्रिब्यूट नोड का नाम वापस करता है, जैसा कि उसका टाइप है。
व्याकरण
अट्रोब्यूट.nodeName
उदाहरण
नीचे का कोड "books.xml" को xmlDoc में लोड करता है, और category एट्रिब्यूट के नोड नाम, नोड मूल्य और नोड टाइप दिखाता है:
वार xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { यदि (इस.readyState == 4 && इस.status == 200) { माइफ़ंक्शन(इस); } }; xhttp.open("GET", "books.xml", true); xhttp.send(); फ़ंक्शन माइफ़ंक्शन(एक्सएमएल) { वार x, i, xmlDoc, txt; xmlDoc = xml.responseXML; txt = ""; x = xmlDoc.getElementsByTagName('book'); फ़ोर (i = 0; i < x.length; i++) { txt += x.item(i).attributes[0].nodeName + " = " + x.item(i).attributes[0].nodeValue + " (nodetype: " + x.item(i).attributes[0].nodeType + ")" + "<br>"; } document.getElementById("demo").innerHTML = txt; }