0

I'm trying to use the IMPORTHTML() function to get the text inside of a <span> from a website.

What xpath argument do I need, in order to produce the output: Score 50?

<div class="section">
    <div class="left">
        <div id="search" class="input">
            <span class="select-box">Test Section</span>
            <input type="text" id="txtSymbol" class="select-box">
            <input type="button" id="btnHistory" class="input-button">
        </div>
        <span id="score" class="score">Score 50 </span>
    </div>
</div>

These are some of the xpath values I've already tried using, but none of them have worked:

  1. //span[@class='score']/@content I get #N/A
  2. //div[@class='search']/span[@class='score']/@content I get #N/A
  3. //div[@class='search']/span[1]/@content I get #N/A
damon
  • 14,485
  • 14
  • 56
  • 75
Sivakumar Piratheeban
  • 493
  • 4
  • 11
  • 39
  • Element text is accessed with `text()` function instead of `@content` attribute that does not exists. Try this one `//div[@class='search']/following-sibling::span[@id='score']/text()` – LMC Oct 07 '21 at 14:13

1 Answers1

3

As mentioned in this comment, to get the node's text you should use text() instead of @content.

So this should work:

//span[@class='score']/text()
damon
  • 14,485
  • 14
  • 56
  • 75
Prophet
  • 32,350
  • 22
  • 54
  • 79