I\'m using Html Agility Pack to run xpath queries on a web page. I want to find the rows in a table which contain a certain interesting element. In the example below, I wa
I know this isn't what the OP was asking, but if you wanted to find an element that had a descendant with a particular attribute, you could do something like this:
//table[@name='important']/tr[.//*[@attr='value']]
I know it is a late answer but why not going the other way around. Finding all <interestingtag/>
tags and then select the parent <tr>
tag.
//interestingtag/ancestor::tr
Actually, you need to look for a descendant, not a child:
//table[@name='important']/tr[descendant::interestingtag]
"has a descendant named interestintag" is spelled .//interestintag
in XPath, so the expression you are looking for is:
//table[@name='important']/tr[.//interestingtag]