次の方法で共有


replaceData Method

 

Replaces the specified number of characters with the supplied string.

JScript Syntax

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.

Note

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!>

C/C++ Syntax

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.

Versioning

Implemented in: MSXML 3.0 and MSXML 6.0

See Also

IXMLDOMCDATASection
IXMLDOMCharacterData
IXMLDOMComment
IXMLDOMText