Kevus
Kevus

Reputation: 23

XPATH logic AND - how?

(//table[@id="primenimost_table"]/tbody//tr/td[3] and //table[@id="primenimost_table"]/tbody//tr/td[4])

This formula doesn't work.

Example HTML:

<table id="primenimost_table">
    <tbody>
        <tr>
            <td>FORD</td>
            <td>C-MAX II (DXA/CB7, DXA/CEU)</td>
            <td>1.6 TDCi</td>
            <td>12.2010 - </td>
        </tr>

        <tr>
            <td>FORD</td>
            <td>GRAND C-MAX (DXA/CB7, DXA/CEU)</td>
            <td>1.6 Ti</td>
            <td>12.2010 - </td>
        </tr>
    </tbody>

</table>

Need parse
1.6 TDCi 12.2010 -
1.6 Ti 12.2010 -

Upvotes: 1

Views: 26

Answers (1)

kjhughes
kjhughes

Reputation: 111491

This XPath,

//table[@id="primenimost_table"]/tbody/tr/td[position() = 3 or position() = 4]

will select all 3rd and 4th td elements in each tr of the id'ed table.

(Although you want the 3rd and 4th elements, it's actually a logical or against the positions that yields the desired elements.)

Upvotes: 1

Related Questions