XML DOM nodeTypeEigenschaft


Attr-Objekt

Definition und Verwendung

Die Eigenschaft nodeType gibt den Typ eines Knotens zurück.

Syntax

attrObject.nodeType


Beispiel

Der folgende Codeausschnitt verwendetloadXMLDoc(), um "in xmlDoc zu laden und den Knotennamen, Knotenwert und Knotentyp des category-Attributs anzuzeigen:

Beispiel

xmlDoc=loadXMLDoc("books.xml"); 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(" (Knotentyp: " + x.item(i).attributes[0].nodeType + ")"); document.write("<br>"); }

Ausgabe:

category = COOKING (Knotentyp: 2)
category = CHILDREN (Knotentyp: 2)
category = WEB (Knotentyp: 2)
category = WEB (Knotentyp: 2)

Selbst ausprobieren »

Attr-Objektandere Erweiterungen