开发者

xpath: how to not match the following data

Viewing source, I have table data formatted exactly like this:

  <tr class="even">
    <td>apple</td>
    <td>pear</td>
    <td>ora开发者_如何学运维nge</td>
    </tr>
    <tr class="odd">
    <td>apple</td>
    <td>pear</td>
    <td>&nbsp</TD>
    </tr>
  <tr class="even">
    <td>apple</td>
    <td>pear</td>
    <td>orange</td>
    </tr>

How would I go about not matching the <td> containing &nbsp in all rows where it occurs?


The entity &nbsp; isn't something that XPath knows about -- it is best to use its equivalent (self-defining) character entity &#xA0;

To select all td s of a top element - table, that do not contain &nbsp; use:

 /table/tr/td[not(contains(., '&#xA0;'))]

To select all rows of this table such that none of their td children contains &nbsp; use:

 /table/tr[not(td[contains(., '&#xA0;')])]

To select all td children of all rows of this table such that none of their td children contains &nbsp; use:

 /table/tr[not(td[contains(., '&#xA0;')])]/td
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜