<p>Is it possible to use XPath to select only the nodes that have a particular child elements?  For example, from this XML I only want the elements in pets that have a child of 'bar'.  So the resulting dataset would contain the <code>lizard</code> and <code>pig</code> elements from this example:</p>

<pre><code>&lt;pets&gt;
  &lt;cat&gt;
    &lt;foo&gt;don't care about this&lt;/foo&gt;
  &lt;/cat&gt;
  &lt;dog&gt;
   &lt;foo&gt;not this one either&lt;/foo&gt;
  &lt;/dog&gt;
  &lt;lizard&gt;
   &lt;bar&gt;lizard should be returned, because it has a child of bar&lt;/bar&gt;
  &lt;/lizard&gt;
  &lt;pig&gt;
   &lt;bar&gt;return pig, too&lt;/bar&gt;
  &lt;/pig&gt;
&lt;/pets&gt;
</code></pre>

<p>This Xpath gives me all pets: <code>"/pets/*"</code>, but I only want the pets that have a child node of name <code>'bar'</code>.</p>

Here it is, in all its glory
```
```
/pets/*[bar]
```
```
English: Give me all children of
```
pets
```
that have a child
```
bar
```