PROPERTY:  Object::attributes

Object  Attr   CDATASection   CharacterData   Comment   Document   DocumentFragment   DocumentType   Entity   EntityReference   Node   Notation   ProcessingInstruction   Text
The attributes property contains a list of attributes for any node that can have them. It returns a NamedNodeMap object for Element, Entity and Notation nodes, and null for any other type. The NamedNodeMap can then be accessed to obtain values for those attributes. If a valid nodeType does not have any attributes, then the length of the list is set to zero. The example that follows loads an XML page for CD's. The first child node of the root is a 'CD' tag, and these tags have one attribute: a 'ref' attribute whose value is a reference number for the CD.

<CD ref="CCD142">

Having loaded the XML file, the following code then assigns the attributes of this child node to an NamedNodeMap object, and iterates through them displaying them on the page.

Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False

Dim objNamedNodeMap, intAtt, strAttName
Set objNamedNodeMap = objXMLDoc.documentElement.firstChild.attributes
For Each intAtt in objNamedNodeMap
   document.write( & "<br>")


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