如何合并(分组)xpath 结果

How to merge(group) xpath results

我关注table

<table>
<tbody>
    <tr>
        <td>First Row | First Column</td>
        <td>First Row | Second Column</td>
    </tr>
    <tr>
        <td>Second Row | First Column</td>
        <td>Second Row | Second Column</td>
    </tr>
    <tr>
        <td>Third Row | First Column</td>
        <td>Third Row | Second Column</td>
    </tr>
    <tr>
        <td>Forth Row | First Column</td>
        <td>Forth Row | Second Column</td>
    </tr>
    <tr>
        <td>Fifth Row | First Column</td>
        <td>Fifth Row | Second Column</td>
    </tr>
    <tr>
        <td>Sixth Row | First Column</td>
        <td>Sixth Row | Second Column</td>
    </tr>
</tbody>

我需要使用 xpath 表达式来接收分组的 3 条记录:

  1. 第一行 |第二列,第二行 |第二列
  2. 第三行 |第二列,第四行 |第二列
  3. 第五行 |第二列,第六行 |第二列

如何仅使用 xpath 1.0 来实现?

给你,xpath 表达式:

concat(//tr[1]/td[2], ' , ', //tr[2]/td[2], codepoints-to-string(10), //tr[3]/td[2], ' , ', //tr[4]/td[2], codepoints-to-string(10), //tr[5]/td[2], ' , ', //tr[6]/td[2])

以上将return以下字符串:

First Row | Second Column , Second Row | Second Column
Third Row | Second Column , Forth Row | Second Column
Fifth Row | Second Column , Sixth Row | Second Column