XML DOM hasAttributeNS() మాధ్యమం
నిర్వచనం మరియు ఉపయోగం
ప్రస్తుత ఎలమెంట్ నోడ్ కి నిర్దేశించిన నెమోస్ట్రాంస్ మరియు పేరు యొక్క అంశం ఉన్నట్లయితే hasAttributeNS()
ఈ మాధ్యమం ప్రతిఫలిస్తుంది true అయితే లేకపోతే false ప్రతిఫలిస్తుంది.
సంకేతం
hasAttributeNS(ns,name)
పరామీతిలు | వివరణ |
---|---|
ns | అవసరం. కనుగొనేందుకు కావలసిన అంశం నెమోస్ట్రాంస్ ని నిర్దేశిస్తుంది. |
name | అవసరం. కనుగొనేందుకు కావలసిన అంశం పేరు ని నిర్దేశిస్తుంది. |
ఉదాహరణ
ఈ కోడు "books_ns.xml" ని xmlDoc లోకి లోడ్ చేస్తుంది మరియు మొదటి <title> ఎలమెంట్ కి నిర్దేశించిన నెమోస్ట్రాంస్ మరియు పేరు యొక్క ఏ అంశాలు ఉన్నాయో తనిఖీ చేస్తుంది:
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); } }; xhttp.open("GET", "books_ns.xml", true); xhttp.send(); function myFunction(xml) { var xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName("title")[0]; var ns = "https://www.codew3c.com/meishi/"; document.getElementById("demo").innerHTML = x.hasAttributeNS(ns,"lang"); }