Reputation: 5647
I am trying to find all DIV elements have the attribute widget-name and a descendant span tag that have a title attribute.
This is what I am trying.
//div[@widget-name and descendant::span[@title]]"
This seems to almost work but it is missing one element in the Nodes Collection it returns.
Upvotes: 2
Views: 914
Reputation: 52858
This XPath should return all div
's that:
widget-name
attribute span
element (used abbreviated syntax) that:
class
attribute with the value 'title'contains()
in not()
.XPath:
//div[@widget-name and .//span[@class='title'][contains(.,'someTextToKeep')]]
Upvotes: 0
Reputation: 5647
Never mind.
This is what I needed:
//div[@widget-name and descendant::span[@class='title']]
OK - take it back. This is not the complete answer. I am now trying to tweak this to where it returns all except where title is not equal to some text:
//div[@widget-name and descendant::span[@class='title' and [text()[contains(., '{someTextToKeep}'
Anyone see why this would be invalid XPath?
Final answer is:
//div[@widget-name and descendant::span[@class='title' and text()[not(contains(., 'someTextToKeep'))]]]"
Upvotes: 1