XPath //img[contains(@class, 'check')]/ancestor::tr//span[contains(@class, 'date-display-single')]
이 작동하지만, 문제는 각 행에 해당 클래스가 두 개 있습니다 (<span>
). 내가 원하는 것은 처음 <span>
입니다XPath : 특정 속성이있는 첫 번째 요소를 선택하십시오.
[nodeValue] => Friday 7 October 2016
[nodeValue] => Fri 7 Oct 2016
[nodeValue] => Friday 21 October 2016
[nodeValue] => Fri 21 Oct 2016
[nodeValue] => Friday 4 November 2016
[nodeValue] => Fri 4 Nov 2016
: 결과
[nodeValue] => Friday 7 October 2016
[nodeValue] => Friday 21 October 2016
[nodeValue] => Friday 4 November 2016
내가 어떻게 할 수 있습니까?
편집 : HTML은
<table class="views-table cols-6">
<thead>
<tr>
<th class="a" scope="col"></th>
<th class="a" scope="col"></th>
<th class="a" scope="col">1</th>
<th class="a" scope="col">2</th>
<th class="a" scope="col">3</th>
<th class="a" scope="col">4</th>
</tr>
</thead>
<tbody>
<tr class="odd views-row-first">
<td class="a"><span class="date-display-single">Friday 7
October 2016</span></td>
<td class="a"><span class="date-display-single">Fri 7 Oct
2016</span></td>
<td class="a"><img alt="Yes" class="check" src="image.png"
title="Yes"></td>
<td class="a"></td>
<td class="a"></td>
<td class="a"></td>
</tr>
<tr class="even">
<td class="a"><span class="date-display-single">Friday 14
October 2016</span></td>
<td class="a"><span class="date-display-single">Fri 14 Oct
2016</span></td>
<td class="a"></td>
<td class="a"><img alt="Yes" class="check" src="image.png"
title="Yes"></td>
<td class="a"><img alt="Yes" class="check" src="image.png"
title="Yes"></td>
<td class="a"><img alt="Yes" class="check" src="image.png"
title="Yes"></td>
</tr>
</tbody>
</table>
그것은 귀하의 게시물과 같은
은 대부분 코드; 자세한 내용을 추가하십시오.
XPath에 문제가있는 HTML 축소 샘플을 게시하십시오. 감사. – kjhughes
Added.123456789 –