title: XPath to find nearest ancestor element that contains an element that has an attribute with a certain value
body: <p><code>ancestor::foo[bar[@attr="val"]]</code></p>
  
  <p>I thought this would work, but it's not. I need to find the nearest <code>foo</code> element going up in the tree that has a <code>bar</code> child element, which in turn has an <code>attr</code> attribute of <code>val</code>.</p>