The length property returns the length of the text in a comment node (in characters).
The following code fragment loads "books_comment.xml" into xmlDoc using loadXMLDoc(), gets the text node data and length from the first <title> element:
The output of the code above will be:
In the example above we use a loop and an if-test to make sure we only process comment nodes. A comment node has a node type of 8.