开发者

Xpath - How to select parent based on attribute of child?

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

I wa开发者_StackOverflownt 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']


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

//*[@id='outer']/div/div/div/div[a[@href='www.blah.com']]


//*[@id='outer']/div/div/div/div/a[@href='www.blah.com']/../
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜