title: How to use lxml to find an element by text?
body: <p>Assume we have the following html:</p>
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;a href=&quot;/1234.html&quot;&gt;TEXT A&lt;/a&gt;
          &lt;a href=&quot;/3243.html&quot;&gt;TEXT B&lt;/a&gt;
          &lt;a href=&quot;/7445.html&quot;&gt;TEXT C&lt;/a&gt;
      &lt;body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>How do I make it find the element &quot;a&quot;, which contains &quot;TEXT A&quot;?</p>
  <p>So far I've got:</p>
  <pre class="lang-py prettyprint-override"><code>root = lxml.html.document_fromstring(the_html_above)
  e = root.find('.//a')
  </code></pre>
  <p>I've tried:</p>
  <pre><code>e = root.find('.//a[@text=&quot;TEXT A&quot;]')
  </code></pre>
  <p>but that didn't work, as the &quot;a&quot; tags have no attribute &quot;text&quot;.</p>
  <p>Is there any way I can solve this in a similar fashion to what I've tried?</p>