PROPERTY:  CharacterData::data

The data property contains the data for this node, depending on node type. A string will be returned by nodes of type NODE_CDATA_SECTION, NODE_COMMENT and NODE_TEXT (see the Node object). The value of the data property for such nodes will be the same as that of the nodeValue property.

The following example uses the 'albums.xml' file and uses the data property to display the text of the various 'artist' elements.

   <Album ref="CD142" category="Folk">
      <title>Boil The Breakfast Early</title>
      <artist>The Chieftains</artist>
   <Album ref="CD720" category="Pop">
      <title>Come On Over</title>
      <artist>Shania Twain</artist>
   <Album ref="CD024" category="Country">
      <title>Red Dirt Girl</title>
      <artist>Emmylou Harris</artist>

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

artists = xml_doc.getElementsByTagName("artist");
n_artists = artists.length;
for (i = 0; i < n_artists; i++)
   document.write(artists[i] + "<br>");

The Chieftains
Shania Twain
Emmylou Harris

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