Retrieves a substring of the full string from the specified range.
strValue = oXMLDOMCharacterData.substringData(offset, count);
A string. Returns the substring.
The following script example creates an IXMLDOMComment
object (comment), and then uses the substringData
method to retrieve the first five characters of the object.
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0"); var comment; var MyStr; 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!"); MyStr = comment.substringData(0, 5); alert(MyStr); }
strValue = oXMLDOMCharacterData.substringData(offset, count)
A string. Returns the substring.
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.
Dim xmlDoc As New Msxml2.DOMDocument50 Dim comment As IXMLDOMComment Dim MyStr As String 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!") MyStr = comment.substringData(0, 5) MsgBox MyStr End If
HRESULT substringData( long offset, long count, BSTR *data);
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.
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.
Applies to: IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMText