S
S
sorry_i_noob2019-02-12 22:44:51
XPath
sorry_i_noob, 2019-02-12 22:44:51

Where is the error in my XPath selector?

Hello. There is such an XPath selector:

//div[contains(@class,"wrapper")]//tr[contains(@class,"table__row") and .//span[contains(@class, "campaign-info-number") and contains(text(),'302177')]]

I want to find a tr that has the class "table__row" and that has a span child that has the class "campaign-info-number" and the content of that span is "302177". tr has a div ancestor that has the "wrapper" class.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
grinat, 2019-02-12
@grinat

And in what language and with what library is this problem? Usually, by default, libraries are searched only for a simple xpath, and separate methods are used to calculate such expressions, and support for structures is not always complete, because, for example, either xpath 1.0 support may be available, and you use expressions from xpath 2.0

R
Roman Fov, 2019-02-13
@Roman-Fov

XML

<div>
  <div class="asdf wrapper">
    <table>
      <tr class="table__row">
        <td>
          <span class="campaign-info-number">302177</span>
        </td>
      </tr>
      <tr class="table__row">
        <td>
          <span class="campaign-info-number">302178</span>
        </td>
      </tr>
      <tr class="table__row">
        <td>
          asdf
        </td>
      </tr>
    </table>
  </div>
</div>

XPath
result
<tr class="table__row">
  <td>
    <span class="campaign-info-number">302177</span>
  </td>
</tr>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question