I am trying to find the minimum value in a certain element from an XML document (it's actually a HTML table that is translated to XML). However, this does not work as intended.
The query is similar to the one used in How can I use XPath to find the minimum value of an attribute in a set of elements?. It looks like this:
/table[@id="search-result-0"]/tbody/tr[
not(substring-before(td[1], " ") > substring-before(../tr/td[1], " "))
]
Executed on the example XML
<table class="tablesorter" id="search-result-0">
<thead>
<tr>
<th class="header headerSortDown">Preis</th>
<th class="header headerSortDown">Zustand</th>
</tr>
</thead>
<tbody>
<tr>
<td width="45px">15 CHF</td>
<td width="175px">Ausgepack und doch nie gebraucht</td>
</tr>
<tr>
<td width="45px">20 CHF</td>
<td width="175px">Ausgepack und doch nie gebraucht</td>
</tr>
<tr>
<td width="45px">25 CHF</td>
<td width="175px">Ausgepack und doch nie gebraucht</td>
</tr>
<tr>
<td width="45px">35 CHF</td>
<td width="175px">Ausgepack und doch nie gebraucht</td>
</tr>
<tr>
<td width="45px">14 CHF</td>
<td width="175px">Gebraucht, aber noch in Ordnung</td>
</tr>
<tr>
<td width="45px">15 CHF</td>
<td width="175px">Gebraucht, aber noch in Ordnung</td>
</tr>
<tr>
<td width="45px">15 CHF</td>
<td width="175px">Gebraucht, aber noch in Ordnung</td>
</tr>
</tbody>
</table>
the query returns the following result:
<tr>
<td width="45px">15 CHF</td>
<td width="175px">Ausgepack und doch nie gebraucht</td>
</tr>
-----------------------
<tr>
<td width="45px">14 CHF</td>
<td width="175px">Gebraucht, aber noch in Ordnung</td>
</tr>
-----------------------
<tr>
<td width="45px">15 CHF</td>
<td width="175px">Gebraucht, aber noch in Ordnung</td>
</tr>
-----------------------
<tr>
<td width="45px">15 CHF</td>
<td width="175px">Gebraucht, aber noch in Ordnung</td>
</tr>
Why are there more nodes returned than one? There should only be exactly one node returned as there is only a single minimum. Does anybody see what's wrong with the query? It should only return the node containing the 14 CHF
.
Results obtained using http://xpath.online-toolz.com/tools/xpath-editor.php