This method returns a substring consisting of the specified range of characters.
The substringData method returns a substring of this string consisting of the specified range of characters. If the range goes beyond the last character in the string, only those characters up to and including the last are copied.
XML:
<currencies>
<currency>CHF Swiss Francs</currency>
<currency>DEM German Deutsche Marks</currency>
<currency>GBP United Kingdom Pounds</currency>
<currency>JPY Japanese Yen</currency>
<currency>USD United States Dollars</currency>
</currencies>
VBScript:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("currencies.xml")
Set Elem = objXMLDoc.documentElement.lastChild
Set Text = Elem.firstChild
Substr = Text.substringData(4, 30)
document.write(Substr)
United States Dollars
In this example, the 'currencies.xml' file is loaded and a substring created from the text of the last 'currency' element. The substring starts with the fifth and ends with the last character of the string (the 'count' parameter is slightly generous and goes beyond the end of the string). The substring is then displayed.