我是Xpath的新手 . 我试着编写一个xpath表达式,它返回上表行中的所有有效元素(标记为'Required') .

XPath使用:

.//*[@id='reportListItemID0']/td[not(@width) and child::node()] | .//*[@id='reportListItemID0']/td[not(@width) and not(child::node())]

<tr style="" class="deatilRow" id="reportListItemID0" nowrap="">
    <td width="10px">&nbsp;</td>
    <td>04/04/2013</td><!----------------------------Required-->
    <td width="3px" colspan="10">&nbsp;</td>
    <td>Morkel, Rashid</td><!------------------------Required-->
    <td width="3px" colspan="10">&nbsp;</td>
    <td>100668041</td><!-----------------------------Required-->
    <td width="3px" colspan="10">&nbsp;</td>
    <td></td><!--------------------------------------Required-->
    <td width="3px" colspan="10">&nbsp;</td>
    <td>
        <a href="javascript:makePost(somelink);" class="dynamicLinks">XA0404181004596</a><!--Required-->
    </td>
    <td width="3px" colspan="10">&nbsp;</td>
    <td>$31.00</td><!--------------------------------Required-->
    <td width="3px" colspan="10">&nbsp;</td>
    <td>
        <span class="workedYesNoColor">N</span><!----Required-->
    </td>
    <td width="3px" colspan="10">&nbsp;</td>
</tr>

使用的X-Path返回下面列出的元素:

<td>04/04/2013</td>
<td>Morkel, Rashid</td>
<td>100668041</td>
<td></td>
<td> <a href="javascript:..." class="dynamicLinks">XA0404181004596</a> </td>
<td>$31.00</td>
<td> <span class="workedYesNoColor">N</span> </td>

但预期结果如下:(叶节点只需要而不是'td')

<td>04/04/2013</td>
<td>Morkel, Rashid</td>
<td>100668041</td>
<td></td>
<a href="javascript:..." class="dynamicLinks">XA0404181004596</a>
<td>$31.00</td>
<span class="workedYesNoColor">N</span>

重要说明:带有标签'a'和'span'的'td'的位置可能会有所不同 . 他们并不是第5和第6位 .

请让我知道我错过了什么 .