METHOD:  CharacterData::substringData

CharacterData.substringData(offset, count)

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.

In the following 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.

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>

Code (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)

Output:
United States Dollars



Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information