代码之家  ›  专栏  ›  技术社区  ›  Eric

如何编写只选择非空子级的XPath选择器?

  •  1
  • Eric  · 技术社区  · 14 年前

    我想编写一个XPath表达式,选择所有非空的 table:table-cell

    2 回复  |  直到 14 年前
        1
  •  1
  •   user357812 user357812    14 年前

    选择所有 table:table-cell 儿童

    table:table-cell[node()]
    

    注意 :此元素不是空的:

    <table:table-cell>Something</table:table-cell>
    

    table:table-cell[count(*) > 0] 不选择它,因为它意味着: 全部的 至少有一个孩子的孩子 要素 小孩

        2
  •  1
  •   Eric    14 年前

    知道了:

    table:table-cell[count(*) > 0]