Replaces the specified number of characters with the supplied string.
oXMLDOMCharacterData.replaceData(offset, count, data);
The following script example creates a new IXMLDOMComment object, and then replaces the first five characters with a new string.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var comment;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
var myErr = xmlDoc.parseError;
alert("You have error " + myErr.reason);
} else {
comment = xmlDoc.createComment("Hello World!");
alert(comment.xml);
comment.replaceData(0, 5, "Goodbye, Cruel");
alert(comment.xml);
}
oXMLDOMCharacterData.replaceData(offset, count, data)
The following Microsoft® Visual Basic® example creates a new IXMLDOMComment object, and then replaces the first five characters with a new string.
Dim xmlDoc As New Msxml2.DOMDocument50
Dim comment As IXMLDOMComment
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
Set comment = xmlDoc.createComment("Hello World!")
MsgBox comment.xml
comment.replaceData 0, 5, "Goodbye, Cruel"
MsgBox comment.xml
End If
HRESULT replaceData(
long offset,
long count,
BSTR data);
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
Applies to: IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMText