1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

XPathで特定のテキストを含む要素を含む一番小さな(近い)tableを選択する

Last updated at Posted at 2015-02-17
$x('//*[text()="テキスト"]/ancestor::table[1]')

/ancestorでヒットした要素の親が全部取れて来るのでそこから::で選択,最初の要素を取ればclosestなものがある

また,次のようにも書けるが,こちらは要素の変更に弱い

$x('//table[tbody/tr/td/b/text()="テキスト"]')
`````

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?