METHOD:  CharacterData::replaceData

CharacterData.replaceData(offset, count, data)

The replaceData method replaces the characters from the specified offset with the supplied string data.

In the following example, the 'albums.xml' file is loaded and the word 'Breakfast' in the 'title' element of the first 'album' is replaced with 'Dinner'.

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

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

Set Elem = objXMLDoc.documentElement.firstChild.firstChild
Set Text = Elem.firstChild
Text.replaceData 9, 9, "Dinner"
document.write(Text.Data)

Output:
Boil The Dinner Early



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