PROPERTY:  Attr::value


The value property returns the value for the attribute. This will either be the value specified in the XML file or, if there isn't one but the attribute has a default value assigned in a DTD, a default value. This property is returned as a string with character and general entity references being replaced with their values.

The following example uses the 'staff.xml' file and obtains a NamedNodeMap of all the attributes of the first child element of the document's root node. It then iterates through them displaying their values.

   <employee ssn="123456" pay="3">
   <employee ssn="987654" pay="2">

Code (JavaScript):
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;

employee = xml_doc.documentElement.firstChild;
atts = employee.attributes;
n_atts = atts.length;
for (i = 0; i < n_atts; i++)
   document.write(atts[i].value + "<br>");


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information