Home>

I want to get the value of td outside the tr tag in Xpath

I want to get the value of td in the 12th row in a table like the one below, but it doesn't work.

1.0.<tbody>
2.0.<tr>...</tr>
3.<tr>
4.<th>...</th>
5.<td>...</td>
6.</tr>
7.<tr>...</tr>
8.<tr>...</tr>
9.<tr>...</tr>
10.<tr>...</tr>
11.<th>...</th>
12.<td>...</td>
13.<tr>...</tr>
14.<tr>...</tr>
15.<tr>...</tr>
16.</tbody>


The td in the tr tag like the 3rd to 6th lines is
// * [@ id ='infotablefont'] // tr [2]/td [1]
I can get it like this, but I don't know how to get td outside the tr tag like the 12th line.
Thank you.

Supplementary information (FW/tool version, etc.)
swift5, xcode12
Parser: Kanna

  • Answer # 1

    // * [@ id ='infotablefont']/td [1]
    By writing, I was able to get the value of td safely.
    Thank you very much.

  • Answer # 2

    As a general rule for scraping, consider an XPath or CSS selector that displays the raw HTML just before parsing and looks at it to identify the element.

  • Answer # 3

    // * [@ id ='infotablefont']/td [1]
    By writing, I was able to get the value of td safely.
    Thank you very much.

  • Answer # 4

    // * [@ id ='infotablefont']/td [1]
    By writing, I was able to get the value of td safely.
    Thank you very much.