Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xpath: decipher this xpath?

Tags:

xpath

what does this xpath mean ? can someone decipher this ?

//h1[following-sibling::*[1][self::b]]
like image 239
KJW Avatar asked Nov 15 '10 11:11

KJW


1 Answers

Select every h1 element (in the document of the context node) that is immediately followed by a b element (with no other intervening element, though there may be intervening text).

Breaking it down:

//h1

Select every h1 element that is a descendant of the root node of the document that contains the context node;

[...]

filter out any of these h1 elements that don't meet the following criteria:

[following-sibling::*[1]...]

such that the first following sibling element passes this test:

[self::b]

self is a b element. Literally, this last test means, "such that when I start from the context node and select the self (i.e. the context node) subject to the node test that filters out everything except elements named b, the result is a non-empty node set."

like image 92
LarsH Avatar answered Oct 23 '22 01:10

LarsH