[XPath] 如何使用 XPath 选取指定多个属性的元素

在当前节点下,选取它所有同时具备 href 和 lmv 属性的后代元素。

 

使用 and 语法的 XPath 表达式:

./descendant::*[@href and @lmv] 或者 .//*[@href and @lmv] 

 

指定 lmv 属性值为"电视剧"的 XPath 表达式:

./descendant::*[@href and @lmv='电视剧'] 或者 .//*[@href and @lmv='电视剧']

 

在当前节点下,选取它所有具备href或lmv属性的后代。

 

使用 "|" 语法的 XPath 表达式:

./descendant::*[@href|@lmv] 或者 .//*[@href|@lmv]

 

注:以上 lmv 为自定义属性。

posted @ 2014-04-17 11:30  iFantasticMe  阅读(21000)  评论(0编辑  收藏  举报