T
T
timers2021-10-05 17:10:44
HTML
timers, 2021-10-05 17:10:44

How to select the desired element in blocks through XPATH?

HTML

<div class="item">
  <span class="lock">Блок</span>
  <a href="#" class="links">Ссылка №1</a>
</div>
<div class="item">
  <span class="lock">Блок</span>
  <a href="#" class="links">Ссылка №2</a>
</div>
<div class="item">
  <span class="lock">Блок</span>
  <a href="#" class="links">Ссылка №3</a>
</div>
<div class="item">
  <a href="#" class="links">Ссылка №4</a>
</div>
<div class="item">
  <a href="#" class="links">Ссылка №5</a>
</div>
<div class="item">
  <a href="#" class="links">Ссылка №6</a>
</div>
и тд.


What I need to do is to define blocks only without "Block", i.e. did a check about all blocks for the presence of text or a class, if it is there, then I don’t need it.

I do this:
>XPATH> //div//a[contains(@class, "links")] - this is how it finds all blocks, but I need everything only without span

Tell me how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2021-10-05
@ScriptKiddo

xpather.com/pTE4NahP

img
615c5f0b6b257554343470.png

//div/a[@class='links' and not(../span)]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question