Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
DOM
Expand Minimize

insertData Method

Inserts a string at the specified offset.

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.

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


Output

<!--Hello Beautiful World!>

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.

The length property is updated by this operation.

Implemented in: MSXML 3.0 and MSXML 6.0

Show:
© 2015 Microsoft