我想把每個單元格的所有信息放在一行中的表格中。我需要弄清楚如何打印表格中每列的標題。如何使用XPath獲取表格中的上述單元格?
td, table {
border: 2px black solid;
}
<table>
<tr>
<td>a1</td>
<td>a2</td>
<td>a3</td>
<td>a4</td>
</tr>
<tr>
<td>b1</td>
<td>b2</td>
<td>b3</td>
<td>b4</td>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3</td>
<td>c4</td>
</tr>
<tr>
<td>d1</td>
<td>d2</td>
<td>d3</td>
<td>d4</td>
</tr>
</table>
Table 1
+----+----+----+----+
| a1 | a2 | a3 | a4 |
+----+----+----+----+
| b1 | b2 | b3 | b4 |
+----+----+----+----+
| c1 | c2 | c3 | c4 |
+----+----+----+----+
| d1 | d2 | d3 | d4 |
+----+----+----+----+
Table 2
+----+----+----+----+
| e1 | e2 | e3 | e4 |
+----+----+----+----+
| f1 | f2 | f3 | f4 |
+----+----+----+----+
| g1 | g2 | g3 | g4 |
+----+----+----+----+
| h1 | h2 | h3 | h4 |
+----+----+----+----+
And Other Tables ...
我想獲得在塔的頂部印有細胞的細胞(即T R [1])。
輸出應該不具有第一原始..
第一輸出應爲:
單元B1具有頭A1
..
細胞G2具有標頭e2
等等。
我使用xidel:
xidel $site -e "//tr[position()>1]/td/concat('The cell ', ., $codeX)"
的$codeX
值應該是什麼?
感謝,
如果你想使用第一行,那麼聽起來好像使用'// tr [1]/td'就是你想要的 –
@MartinHonnen我想從第二行得到它,實際上我使用的是concat( )將它們一起打印。 – user37421