XML DOM nodeValue-eigenschap
Definitie en gebruik
De nodeValue-eigenschap stelt of retourneert de waarde van het knooppunt op basis van het type van het knooppunt.
Syntaxis:
attrObject.nodeValue
voorbeeld
In alle voorbeelden gebruiken we XML-bestanden books.xmlen plus JavaScript functie loadXMLDoc().
The following code snippet shows the node name, node value, and node type of the category attribute:
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 />");
}
The output of the above code is:
category = children (nodetype: 2) category = cooking (nodetype: 2) category = web (nodetype: 2) category = web (nodetype: 2)