【发布时间】:2016-05-02 05:14:28
【问题描述】:
基本上我有一份总统名单,我只对尼克松链接感兴趣,而不是克林顿或奥巴马。 我发现,我所做的过滤返回了正确数量的总统(在这种情况下为 1),但返回了所有 a 链接,而不仅仅是尼克松的链接。
HTML:
<a href="#" name="obama"></a> <div class="headlineBlock">
<h2>Obama</h2>
<p class="tudor"><strong>Conditions:</strong> Always sunny </p>
<table class="resultGrid"><tr> <td class="first">
<h4><a href="http://www.thelinkiwant.com?params" title="Click to view result"</a></h4>
<a href="#" name="nixon"></a> <div class="headlineBlock">
<h2>Nixon</h2>
<p class="nixon"><strong>Conditions:</strong> Sometimes late </p>
<table class="resultGrid"><tr> <td class="first">
<h4><a href="http://www.thelinkiwant.com/?params" title="Click to view result"</a></h4>
<a href="#" name="clinton"></a> <div class="headlineBlock">
<h2>Clinton</h2>
<p class="tudor"><strong>Conditions:</strong> Never rainy </p>
<table class="resultGrid"><tr> <td class="first">
<h4><a href="http://www.thelinkiwant/?params" title="Click to view result"</a></h4>
XPATH:
$x("//div[@class='headlineBlock']/h2[not(contains('|Clinton|Obama|',concat('|',.,'|') ))]//../../table/a/@href")
【问题讨论】:
标签: xpath