XPath 1 - 下一个兄弟之间的唯一兄弟匹配,只有下一个兄弟之间的匹配(不是贪婪的匹配)

时间:2017-09-10 02:13:44

标签: xpath

在这个人的内表面上敲我的头:

<table class="magic">
  <tbody>
    <!-- previous sections here -->

    <!-- uninteresting section example begin -->
    <tr class="head">
      <th colspan="2">Spain</th>
    </tr>
    <!-- ... -->
    <tr class="section-break"></tr>
    <!-- uninteresting section example end -->

    <!-- begin interesting section (position not fixed) -->
    <tr class="head">
      <th colspan="2">United States</th>
    </tr>
    <tr></tr>  <!-- match here begin (length not fixed) -->
    <tr></tr> 
    <!-- ... -->
    <tr></tr>  <!-- match here end -->
    <tr class="section-break"></tr>
    <!-- end interesting section -->

    <!-- next sections -->
    <!-- ... -->
    <tr class="section-break"></tr>
    <!-- ... -->
    <tr class="section-break"></tr>
    <!-- ... -->
  </tbody>
<table>

到目前为止:

/table[@class="magic"]/tbody/tr[following-sibling::tr/th[text()="United States"] and preceding-sibling::tr[contains(@class,"section-break")][12345]]

^--- evil magic constant 12345: must not be hard-coded, probably some sort of `count()`constraint  or Kayessian ?

但如何找到section-break之后的第一个United States

1 个答案:

答案 0 :(得分:1)

SELECT STUDENT, AVG( NOT_NOT*1.0 )
FROM NOTAS
WHERE FECH_NOT >= '2003-01-01' AND FECH_NOT < '2004-01-01'
GROUP BY STUDENT;