XML DOM deleteData() Method
Definition and Usage
The deleteData() method deletes data from the comment node.
Syntax:
commentNode.deleteData(start,length)
parameter | description |
---|---|
start | is required. The position of the first character to be deleted. |
length | is required. The number of characters to be deleted. |
description
This method from start the specified character starts, delete length characters. If start add length If the character count is greater than the Comment node, then delete from start All characters from the start to the end of the string.
Example
The following code segment uses JavaScript functions loadXMLDoc() Load an XML file books_comment.xml Load xmlDoc and then delete some characters from the first comment node:
xmlDoc=loadXMLDoc("books_comment.xml");
x=xmlDoc.getElementsByTagName("book")[0].childNodes;
for (i=0;i<x.length;i++)
{
if (x[i].nodeType==8)
{
//Only process comment nodes
x[i].deleteData(0,9);
document.write(x[i].data);
document.write("<br />");
}
}
The output of the above code:
(Hardcover)
In this example, we use a loop and if statement to perform processing that targets only comment nodes. The node type of the comment node is 8.
Try It Yourself (TIY)
Related Pages
XML DOM Reference Manual:CharacterData.deleteData()