So I have something like this
<img src="/icons/folder.gif" alt="[DIR]"> <a href="convobot-main/">convobot-main/</a>
and I want to select the a href only when the img tag has the attribute alt = "[Dir]". How can I achieve this?
CodePudding user response:
This XPath,
//img[@alt='[DIR]']/following-sibling::a[1]/@href
will select href attributes of all first a siblings of all img elements with an alt attribute value of '[DIR]'.
