Freigeben über


insertData Method

 

Inserts a string at the specified offset.

JScript Syntax

oXMLDOMCharacterData.insertData(offset, data);  

Parameters

offset
A long integer specifying the offset, in characters, at which to insert the supplied string data.

data
A string containing the data that is to be inserted into the existing string.

Example

The following script example creates an IXMLDOMComment object and uses the insertData method to insert a string into it.

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!");
   comment.insertData(6, "Beautiful ");
   WScript.Echo(comment.xml);
}

Output

<!--Hello Beautiful World!>

C/C++ Syntax

HRESULT insertData(  
    long offset,  
    BSTR data);  

Parameters

offset[in]
The offset, in characters, at which to insert the supplied string data.

data[in]
The string data that is to be inserted into the existing string.

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.

Remarks

The length property is updated by this operation.

Versioning

Implemented in: MSXML 3.0 and MSXML 6.0

See Also

length Property (IXMLDOMCharacterData)
IXMLDOMCDATASection
IXMLDOMCharacterData
IXMLDOMComment
IXMLDOMText