-
Notifications
You must be signed in to change notification settings - Fork 94
Description
Note: I have experienced this issue using htmlquery, but it seems to not be fixed here either, so I am raising issue here.
By xpath spec, /descendant::span[1] and //span[1] are not the same.
/descendant::span[1] should get the first span descendant matched within the current ancestor, while //span[1] should get the first span descendant matched within the parent of each respective span element. This package seems to currently be treating both like //span[1]
Example:
<div id="wrapper">
<span>span one</span>
<div>
<span>span two</span>
</div>
</div>
In this case, //div[@id='wrapper']//span[1]
should be matching both span one and span two, because both are the first child of their respective parents. However, //div[@id='wrapper']/descendant::span[1]
should only match span one, as it goes by the position within div[@id='wrapper']
, not position within direct parent.
See xpath spec 2.5
NOTE: The location path //para[1] does not mean the same as the location path /descendant::para[1]. The latter selects the first descendant para element; the former selects all descendant para elements that are the first para children of their parents.