I have an org.w3c.dom.Node object.
I would like to see if he has other brothers and sisters.
Here is what I tried:
Node sibling = node.getNextSibling();
if(sibling == null)
return true;
else
return false;
HOWEVER, for some reason (possibly due to identification or spaces in the source XML), I am not getting the expected result.
[Besides
node.getParentNode().getChildNodes().getLength()
gives a value higher than I expected.]
I welcome your suggestions for improving this code.
EDIT
As shown below, the empty nodes seem to interfere with my attempts to count brothers and sisters.
xml looks something like this:
<a>
<b>
<c>I have this node:</c>
<c>I want to know how many of these there are.</c>
<c>This is another sibling.</c>
</b>
<b>
</b>
</a>
Starting from my node (first <c> </c> above), how do I find out the number of other siblings?
source
share