XML DOM length Property
Comment Object
Definition and Usage
The length property returns the length of the text in a comment node (in characters).
Syntax
commentNode.length
Example
The following code snippet uses loadXMLDoc() to load "books_comment.xml" Load into xmlDoc, and from the first
Example
xmlDoc=loadXMLDoc("books_comment.xml");
x=xmlDoc.getElementsByTagName("book")[0].childNodes;
for (i=0;i { if (x[i].nodeType==8) { //Process only comment nodes document.write(x[i].length); document.write(" "); } } The code above will output: 44 Try it » In the example above, we use a loop and an if statement to perform processing only on comment nodes. The node type of a comment node is 8.
Comment Object