LoginSignup
1
0

More than 5 years have passed since last update.

特定の文字列を含む配下にbrタグ以外の要素を持たない要素を選択する

Posted at

fooという文字列を含むが配下にbrタグ以外の要素を持たない要素を選択する xpath.

//div[contains(.,"foo") and (not(*) or br)]'

特にdivタグはそこらじゅうで使われているので入れ子構造の一番中のもののみ選択しないと困ったことになるので使います。

もちろんid要素やその他のもっとわかりやすい物で取得できならそちらを使いましょう。これはテキストしか要素に唯一性が無い時の対処方法です。

1
0
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
0