XML DOM » CharacterData » deleteData

Syntax:
characterData.deleteData(offset, count)
offset
Receives the index of the initial character in the substring to delete.
count
Receives the number of characters to be deleted beginning at offset.

This method is used to remove the specified range of characters from string data.

The deleteData method is used to remove the specified range of characters from string data. The two parameters specify the index of the initial character of the substring to delete, and the number of characters respectively. If this range goes beyond the end of the string, only those characters to the end of the string are deleted. The data and length properties are both immediately updated by this method.

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 tef="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.firstChild
Elem.deleteData 5, 4
document.write(Elem.data)
Output:
Boil Breakfast Early
Explanation:

In this example we use the 'albums.xml' file and delete the word 'The ' from the 'title' of the first 'album' element.

Language(s): VBScript XML