2017-07-22 4 views
-1

I TabelleWie fusionieren (Gruppe) XPath Ergebnisse

folgende Haben
<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> 

Ich brauche xpath expresion zu verwenden, um gruppiert 3 Datensätze zu erhalten:

  1. Erste Zeile | Zweite Spalte, zweite Zeile | Zweite Spalte
  2. Dritte Zeile | Zweite Spalte, weiter Zeile | Zweite Spalte
  3. Fünfte Reihe | Zweite Spalte, sechste Reihe | Zweite Spalte

Wie kann ich das nur mit Xpath 1.0 erreichen?

+0

Wie man es zu erreichen versuchte? – Andersson

+0

'' '// tr [1 und 3]/td [2]' '' Das macht 6 Datensätze –

Antwort

0

Hier gehen Sie, XPath Ausdruck:

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]) 

Die oben wird die folgende Zeichenfolge zurück:

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

Funktioniert es in Xpath 1.0? –

Verwandte Themen