I want to count the total number of specific nodes between root node and current node.
for Example:
<w:body> <!-- root Node -->
<w:p/>
<w:rect>
<w:p>some text1</w:p>
</w:rect>
<w:p/>
<w:rect>
<w:p>some text2</w:p>
</w:rect>
<w:p/>
<w:p/>
<w:p/>
<w:rect>
<w:p>some text5</w:p> <!-- This is current node now -->
</w:rect>
<w:p/>
<w:p/>
<w:p/>
<w:p/>
</w:body>
This is my scenario.Here, Assume some text is my current node.So, Now i want to get the parent::w:p of the current node (Assume this node name as “targetNode”). After that i want to calculate total number of the same level of w:p from root node to targetNode.
My wanted output is :5
Please Guide me to get out of this issue…
What about this single XPath expression:
In this way we obtain the count of all preceding sibling w:p nodes of the first ancestor w:p + 1 (the first ancestor w:p itself).