XML DOM getNamedItem() နည်းလမ်း
❮ အမည်ရှိNodeMap Object
ဥပမာ
အောက်ဖော်ပြပါ ကုဒ်အပိုင်းအစသည် " 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 x, i, att, xmlDoc,
txt;
xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.getElementsByTagName('book');
for (i = 0; i < x.length; i++) {
att = x.item(i).attributes.getNamedItem("category");
txt += att.value + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
cooking
children
web
web
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
getNamedItem() နည်းလမ်းသည် node အား သီးခြားအမည် (အမည်ရှိသောNodeMap မှ) ဖြင့် ပြန်ပေးသည်။
Browser ပံ့ပိုးမှု
getNamedItem() နည်းလမ်းကို အဓိက ဘရောက်ဆာအားလုံးတွင် ပံ့ပိုးထားသည်။
မှတ်ချက်- Internet Explorer 8 နှင့် အထက်တွင် ဤနည်းလမ်းကို မပံ့ပိုးပါ။
အထားအသို
namedNodeMap.getNamedItem(nodeName)
ကန့်သတ်ချက်များ
Parameter | Type | Description |
---|---|---|
nodeName | String | Required. The name of the node to return |
တန်ဖိုးကို ပြန်ပေးသည်။
Type | Description |
---|---|
Node object | The node with the specified name, , or null if it does not identify any node in the map |
နည်းပညာဆိုင်ရာအသေးစိတ်
DOM ဗားရှင်း | Core အဆင့် ၁ |
---|
ကိုယ်တိုင်စမ်းသုံးကြည့်ပါ-ဒီမိုများ
❮ အမည်ရှိNodeMap Object