Retrieves a substring of the full string from the specified range.
JScript Syntax
|
strValue = oXMLDOMCharacterData.substringData(offset, count); |
Parameters
- offset
-
A long integer value indicating the offset, in characters, from the beginning of the string. An offset of zero indicates copying from the start of the data.
- count
-
A long integer value indicating the number of characters to retrieve from the specified offset.
Return Value
A string. Returns the substring.
Example
The following script example creates an IXMLDOMComment object (comment), and then uses the substringData method to retrieve the first five characters of the object.
Note |
|---|
| You can use books.xml to run this sample code. |
|
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var comment;
var MyStr;
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!");
MyStr = comment.substringData(0, 5);
WScript.Echo(MyStr);
}
|
Output
Visual Basic Syntax
|
strValue = oXMLDOMCharacterData.substringData(offset, count) |
Parameters
- offset
-
A long integer value indicating the offset, in characters, from the beginning of the string. An offset of zero indicates copying from the start of the data.
- count
-
A long integer value indicating the number of characters to retrieve from the specified offset.
Return Value
A string. Returns the substring.
Example
The following Microsoft Visual Basic example creates an IXMLDOMComment object (comment), and then uses the substringData method to retrieve the first five characters of the object.
Note |
|---|
| You can use books.xml to run this sample code. |
|
Dim xmlDoc As New Msxml2.DOMDocument30
Dim comment As IXMLDOMComment
Dim MyStr As String
xmlDoc.async = False
xmlDoc.Load App.Path & "\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!")
MyStr = comment.substringData(0, 5)
MsgBox MyStr
End If
|
Output
C/C++ Syntax
|
HRESULT substringData(
long offset,
long count,
BSTR *data); |
Parameters
- offset[in]
-
The offset, in characters, from the beginning of the string. An offset of zero indicates copying from the start of the data.
- count[in]
-
The number of characters to retrieve from the specified offset.
- data[out, retval]
-
The substring to return.
Return Values
- S_OK
-
The value returned if successful.
- S_FALSE
-
The value when returning Null.
Remarks
If the offset and count parameters indicate a range beyond the end of the string, the returned substring continues only until the end of the string data.
Versioning
Implemented in: MSXML 3.0 and later
See Also