views:

381

answers:

2

How do you select a parent based on the attribute of a child?

I want to select a div:

//*[@id='outer']/div/div/div/div

that has a child with the 'a href' attribute equal to 'www.blah.com':

//*[@id='outer']/div/div/div/div/a[@href='www.blah.com']
+2  A: 
//*[@id='outer']/div/div/div/div/a[@href='www.blah.com']/../
Faruz
+3  A: 

The basic fact you need is that predicates can be nested:-

//*[@id='outer']/div/div/div/div[a[@href='www.blah.com']]
AnthonyWJones
Downvoter: Please state reason?
AnthonyWJones