XPath 1-后一个同级与前一个同级之间的独占同级匹配(非贪婪匹配)
在这辆车上,我的头撞到了车内表面:XPath 1-后一个同级与前一个同级之间的独占同级匹配(非贪婪匹配),xpath,Xpath,在这辆车上,我的头撞到了车内表面: <table class="magic"> <tbody> <!-- previous sections here --> <!-- uninteresting section example begin --> <tr class="head"> <th colspan="2">Spain</th> </tr>
<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>
但是如何在
美国之后找到第一个分节符
?可以将/th[包含(,“美国”)]
替换为th=“美国”
。
//table[@class="magic"]//tr[@class="head" and ./th[contains(., "United States")]]/following-sibling::tr[@class="section-break"][1]
//table[@class="magic"]//tr[@class="head" and ./th[contains(., "United States")]]/following-sibling::tr[@class="section-break"][1]