insertData Method
Inserts a string at the specified offset.
[Script]
Script 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.
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!"); comment.insertData(6, "Beautiful "); alert(comment.xml); }
[Visual Basic]
Visual Basic 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 Microsoft® Visual Basic® example creates an IXMLDOMComment
object and uses the insertData
method to insert a string into it.
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!") comment.insertData 6, "Beautiful " MsgBox (comment.xml) End If
[C/C++]
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.
C/C++ 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.
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.
See Also
Applies to: IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMText