title: How do I match contents of an element in XPath (lxml)?
body: <p>I want to parse HTML with lxml using XPath expressions. My problem is matching for the contents of a tag:</p>
  
  <p>For example given the </p>
  
  <pre><code>&lt;a href="http://something"&gt;Example&lt;/a&gt;
  </code></pre>
  
  <p>element I can match the href attribute using </p>
  
  <pre><code>.//a[@href='http://something']
  </code></pre>
  
  <p>but the given the expression</p>
  
  <pre><code>.//a[.='Example']
  </code></pre>
  
  <p>or even</p>
  
  <pre><code>.//a[contains(.,'Example')]
  </code></pre>
  
  <p>lxml throws the 'invalid node predicate' exception.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Example code:</p>
  
  <pre><code>from lxml import etree
  from cStringIO import StringIO
  
  html = '&lt;a href="http://something"&gt;Example&lt;/a&gt;'
  parser = etree.HTMLParser()
  tree   = etree.parse(StringIO(html), parser)
  
  print tree.find(".//a[text()='Example']").tag
  </code></pre>
  
  <p>Expected output is 'a'. I get 'SyntaxError: invalid node predicate'</p>