XML DOM nodeValue özelliği
Tanım ve Kullanım
nodeValue özelliği, nodun türüne göre ayarlar veya nodun değerini döndürür.
Gramer:
attrObject.nodeValue
Örnek
Tüm örneklerde, XML dosyasını kullanacağız books.xmlve JavaScript fonksiyonu loadXMLDoc()。
Aşağıdaki kod parçası category özelliğinin node adı, node değeri ve node türünü gösterir:
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
var x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].nodeName);
document.write(" = ");
document.write(x.item(i).attributes[0].nodeValue
);
document.write(" (nodetype: ");
document.write(x.item(i).attributes[0].nodeType + ")");
document.write("<br />");
}
Yukarıdaki kodun çıktısı:
category = children (nodetype: 2) category = cooking (nodetype: 2) category = web (nodetype: 2) category = web (nodetype: 2)