Yes, document contains more comments. Some comments dont have previous tag, only having parent tag. I tested tag length but for me its returned only 0. I dono the issue.
Tag name contains prefix. So need I add any namespace or anything else to test??
Yes, ALL namespaces must be declared. And especially in the loop, the problem is that evaluateXPathExpression does not »see« the namespace declatration of the parent tags.
Workaround: temporary Declaration of the namespace
_tempNSDeclaration = _comments.parent.xmlAttributes.add( "xmlns:cl", "http://www.namespace.xyz" );
_precTags = _comments.parent.evaluateXPathExpression("child::comment()/preceding-sibling::*[position() = 1]");
_tempNSDeclaration.remove();
Or iterating over _comments.parent.xmlElements
By the way, it is easier to help you, if you provide a test file with the complete structure.
Roland