What happens when I apply following-sibling::*[1]
to the last child?
views:
32answers:
2
A:
It will get you the first sibling to the current node.
Here is an example:
<Root>
<Div id="Hey">
Test1
</Div>
<Div>
Test2
</Div>
<Div>
Test3
</Div>
</Root>
XPath:
/Root/Div[@id = 'Hey']/following-sibling::*[1]
/Root/Div[@id = 'Hey']
will get you the Div
with id=Hey
and /following-sibling::*[1]
will then get you the first sibling so in total you would get the Div
with the text "Test2".
Update: I apologize (see comment), but this: /Root/Div[3]/following-sibling::*[1]
will just return a empty list. (Div[3]
is the last child)
lasseespeholt
2010-08-26 08:21:57
**-1** The question asked what it did when applied to the _last_ child
Eric
2010-08-26 08:41:13
See my update :-)
lasseespeholt
2010-08-26 09:14:02
+1
A:
What happens when I apply
following-sibling::*[1]
to the last child?
Answer: it gets evaluate to an empty node-set, because there is no more following siblings.
If you want to get the following sibling of the context node or following sibling of context node parent otherwise, the rigth axis is following
, as in:
following::*[1]
Alejandro
2010-08-26 14:37:00