title: How to find elements by attribute namespace in XPath
body: <p>I'm trying to use XPath to find all elements that have an element in a given namespace.</p>
  
  <p>For example, in the following document I want to find the <code>foo:bar</code> and <code>doodah</code> elements:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root xmlns:foo="http://foo.example.com"&gt;
    &lt;foo:bar quux="value"&gt;Content&lt;/foo:bar&gt;
    &lt;widget&gt;Content&lt;/widget&gt;
    &lt;doodah foo:quux="value"&gt;Content&lt;/doodah&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I know I can use the following XPath expression to load all attributes from a given namespace:</p>
  
  <pre><code>"//@*[namespace-uri()='http://foo.example.com']"
  </code></pre>
  
  <p>However:</p>
  
  <ul>
  <li>This doesn't give me the elements, just the attributes.</li>
  <li>Where elements contain multiple attributes from that namespace, this selector will return a result per-attribute rather than per-element</li>
  </ul>
  
  <p>Is it possible to get what I want, or do I  have to gather the attributes and calculate the unique set of elements they correspond to?</p>