Easy Tutorial
❮ Prop Attr Textcontent Met Cdata Appenddata ❯

XML DOM replaceData() Method



Definition and Usage

The replaceData() method replaces data within a comment node.

Syntax

Parameter Description
start Required. Specifies where to replace the characters. The start value is 0-based.
length Required. Specifies how many characters to replace.
string Required. Specifies the string to insert.

Example

The following code snippet uses loadXMLDoc() to load "books_comment.xml" into xmlDoc and replaces "Simple" with "Easy" in the comment node of the first <book> element:

Example

Output:

In the above example, we use a loop and an if statement to perform processing specifically for comment nodes. The node type for comment nodes is 8.


❮ Prop Attr Textcontent Met Cdata Appenddata ❯