XML DOM nodeNameEigenschaft
Attr-Objekt
Definition und Verwendung
Die nodeName-Eigenschaft gibt den Namen eines Knotens zurück, abhängig von seinem Typ.
Syntax
attrObject.nodeName
Beispiel
Der folgende Codeausschnitt verwendetloadXMLDoc(), um "in xmlDoc zu laden und den Knotennamen, den Knotenwert und den 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)
category = CHILDREN (Knotentyp: 2)
category = WEB (Knotentyp: 2)
category = WEB (Knotentyp: 2)
Selbst ausprobieren »
Demos testen
Attr-Objektandere Erweiterungen