XML DOM » CharacterData » replaceData

Syntax:
characterData.replaceData(offset, count, data)
offset
Receives the index of the initial character where the replacement will begin.
count
Receives the number of characters to be replaced beginning at offset.
data
Receives the strnig data that will replace the characters beginning at offset.

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

Examples

Code:
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>

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
Explanation:

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

Language(s): VBScript XML