Find the title you are interested in, and then pull out its table.
// u [b = 'Header1'] / ancestor :: table [1]
or
//td[not(.//table) and .//b = 'Header1'] / ancestor :: table [1]
Note that // always starts with the document root (!). You can not:
// table [// * [contains (text (), "Header1")]]
and expect the internal predicate ( //*β¦ ) to magically start in the right context. Use .// to run in the context of node. Even then, this is:
// table [.//* [contains (text (), "Header1")]]
will not work, since even the outermost table contains the text 'Header1' somewhere deep, so the predicate evaluates to true for each table in your example. Use not() , as I did to make sure other tables are not nested.
Also, do not check the condition on each node .//* , as it cannot be true for each node. It is more effective to be specific.
source share