XML DOM length property
Definition and Usage
length of the Chinese property returns a comment node length (in characters).
grammar
commentNode.length
Examples
The following code fragment uses loadXMLDoc () to " books_comment.xml " into xmlDoc and get text nodes and data length from the first <title> element:
Examples
xmlDoc=loadXMLDoc("books_comment.xml");
x=xmlDoc.getElementsByTagName("book")[0].childNodes;
for (i=0;i<x.length;i++)
{
if (x[i].nodeType==8)
{
//Process only comment nodes
document.write(x[i].length);
document.write("
");
}
}
x=xmlDoc.getElementsByTagName("book")[0].childNodes;
for (i=0;i<x.length;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 some loops and if statements to execute only the processing nodes for comment. Node type comment node is eight.
Comment objects