PROPERTY:  Object::specified

This property is a Microsoft extension to the W3C DOM.

Object  Attr   CDATASection   CharacterData   Comment   Document   DocumentFragment   DocumentType   Entity   EntityReference   Node   Notation   ProcessingInstruction   Text

The specified property returns a boolean value which indicates whether or not this attribute has a value specified in the XML document. If a value is specified in the document then it returns true. If no value is specified in the document, but the DTD for it specifies a default value, then specified returns false. Otherwise, if there is no value assigned in the XML document, and the value assigned to the attribute in the DTD is #IMPLIED, then the attribute does not appear in the structure model for the document.

The following example uses the 'staff.xml' file where the second 'employee' element does not have a 'pay' attribute, but where a default value is specified in the DTD for the document. The code loops through the children of the root element and assigns the attributes of each to a NamedNodeMap. The specified property is then displayed for the 'pay' attribute.

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

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

root = xml_doc.documentElement;
n_children = root.childNodes.length;
for (i = 0; i < n_children; i++)
   curr_node = root.childNodes.item(i);
   atts = curr_node.attributes;
   document.write(atts[1].specified + "<br>");


The specified property will always return true for any node type other than an attribute.

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