Export (0) Print
Expand All
DOM
Expand Minimize
1 out of 1 rated this helpful - Rate this topic

replaceData Method

Replaces the specified number of characters with the supplied string.

oXMLDOMCharacterData.replaceData(offset, count, data);

Parameters

offset

The long integer value specifying the offset, in characters, at which to start replacing string data.

count

The long integer value specifying the number of characters to replace.

data

The string containing the new data that replaces the old string data.

Example

The following script example creates a new IXMLDOMComment object, and then replaces the first five characters with a new string.

NoteNote

You can use books.xml to run this sample code.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
var comment;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   comment = xmlDoc.createComment("Hello World!");
   WScript.Echo(comment.xml);
   comment.replaceData(0, 5, "Goodbye, Cruel");
   WScript.Echo(comment.xml);
}


Output

<!--Hello World!>

<!--Goodbye, Cruel World!>

HRESULT replaceData(
    long offset,
    long count,
    BSTR data);

Parameters

offset[in]

The offset, in characters, at which to start replacing string data.

count[in]

The number of characters to replace.

data[in]

The new data that replaces the old string data.

Return Values

S_OK

The value returned if successful.

S_FALSE

The value when returning Null.

E_FAIL

The value returned if an error occurs.

Implemented in: MSXML 3.0 and MSXML 6.0

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.