XML DOM nodeValueEigenschaft
Attr-Objekt
Definition und Verwendung
Die nodeValue-Eigenschaft legt den Wert eines Knotens fest oder gibt ihn zurück, abhängig von seinem Typ.
Syntax
attrObject.nodeValue
Beispiel
Der folgende Codeausschnitt verwendetloadXMLDoc(), um "es 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)
category = CHILDREN (Knotentyp: 2)
category = WEB (Knotentyp: 2)
category = WEB (Knotentyp: 2)
Selbst ausprobieren »
Attr-Objektandere Erweiterungen