我正在尝试查找具有属性widget-name和具有title属性的后代span标记的所有DIV元素。
这就是我正在尝试的。
//div[@widget-name and descendant::span[@title]]"这看起来几乎可以工作,但它返回的Nodes集合中缺少一个元素。
发布于 2016-08-08 22:46:45
不要紧。
这就是我需要的:
//div[@widget-name and descendant::span[@class='title']]好的-把它收回去。这不是完整的答案。我现在尝试将其调整为返回all,但title不等于某些文本的情况除外:
//div[@widget-name and descendant::span[@class='title' and [text()[contains(., '{someTextToKeep}'有人明白为什么这是无效的XPath了吗?
最终答案是:
//div[@widget-name and descendant::span[@class='title' and text()[not(contains(., 'someTextToKeep'))]]]"发布于 2016-08-08 23:09:20
此XPath应返回符合以下条件的所有div:
widget-name属性span元素( abbreviated syntax):span 'someTextToKeep‘的<代码>D10属性(如果要排除某些文本的跨度,请在not().中将<
XPath:
//div[@widget-name and .//span[@class='title'][contains(.,'someTextToKeep')]]https://stackoverflow.com/questions/38832192
复制相似问题