XML DOM nodeType-eigenschap

Definitie en gebruik

De nodeType-eigenschap retourneert het type van het knooppunt.

Syntaxis:

attrObject.nodeType

Voorbeeld

In alle voorbeelden gebruiken we XML-bestanden books.xmlen en 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)