Eric
Eric

Reputation: 97591

What is the effect of this XPATH expression?

What happens when I apply following-sibling::*[1] to the last child?

Upvotes: 2

Views: 91

Answers (2)

user357812
user357812

Reputation:

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]

Upvotes: 1

Lasse Espeholt
Lasse Espeholt

Reputation: 17782

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)

Upvotes: 0

Related Questions