XML DOM substringData() method
Definition and Usage
The substringData() method from Text or Comment Extract a substring from the node.
Syntax:
CharacterData.substringData(start,length)
Parameter | Description |
---|---|
start | Required. The position of the first character to be returned. |
length | Required. The number of characters in the substring to be returned. |
Return value
Returns a string containing the substring from start starting length number of characters.
throw
This method can throw a DOMException with the following code: DOMException exception:
INDEX_SIZE_ERR - Parameter start or length is negative, or length greater than the length of the Text node or Comment node.
DOMSTRING_SIZE_ERR - The specified text range is too long and cannot be filled into a string in the JavaScript implementation of the browser.
Description
This method extracts from the Text node or Comment node from start starting length number of characters. This method is useful only when the number of characters contained in the text of the node is greater than the maximum number of characters that can be filled into a string in the JavaScript implementation of the browser. In this case, the JavaScript program cannot directly use the data attribute of the Text node or Comment node, but must use a shorter substring of the node text. In practical applications, this situation is unlikely to occur.
Related pages
XML DOM reference manual:Text.replaceData()
XML DOM reference manual:Comment.replaceData()