Given the following table:
<table>
<tr>
<td>Foo</td>
<td>Bar</td>
<td>Buzz</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</table>
Assuming I don't know the fixed position of the value, I'd like to select the 2nd row by giving the 1st row column name, for example:
- Foo => 1
- Bar => 2
- Buzz => 3
Currently I know how to get the name of the column (1st row):
$ pup -f table.html 'td:contains("Foo") text{}'
Foo
I know how to return the next column by:
$ pup -f table.html 'td:contains("Foo") + td text{}'
Bar
I would expect to get the next row by:
$ pup -f table.html 'td:contains("Foo") + tr text{}'
but it doesn't return anything (I expect to be 1
).
Here is the solution with jQuery, but I expect the solution to work with pup
command.
I've checked Mozilla's CSS selector docs page, but I couldn't find anything suitable.