$x('//*[text()="テキスト"]/ancestor::table[1]')
/ancestor
でヒットした要素の親が全部取れて来るのでそこから::
で選択,最初の要素を取ればclosestなものがある
また,次のようにも書けるが,こちらは要素の変更に弱い
$x('//table[tbody/tr/td/b/text()="テキスト"]')
`````
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
$x('//*[text()="テキスト"]/ancestor::table[1]')
/ancestor
でヒットした要素の親が全部取れて来るのでそこから::
で選択,最初の要素を取ればclosestなものがある
また,次のようにも書けるが,こちらは要素の変更に弱い
$x('//table[tbody/tr/td/b/text()="テキスト"]')
`````
Register as a new user and use Qiita more conveniently
Go to list of users who liked