title: XPath: How to check if an attribute exists?
body: <p>Given the following XML, how do I write an XPath query to pull nodes where the attribute <code>foo</code> exists?:</p>
  
  <pre><code>&lt;node1&gt;
    &lt;node2&gt;
      &lt;node3 foo='bar'&gt;&lt;/node3&gt;
      &lt;node3&gt;&lt;/node3&gt;
      &lt;node3 bar='foo'&gt;&lt;/node3&gt;
      &lt;node3 foo='foobar'&gt;&lt;/node3&gt;
    &lt;/node2&gt;
  &lt;/node1&gt;
  </code></pre>