title: Extracting the value of a specific HTML element using XPath in Python
body: <p>I have tried this</p>
  
  <pre><code>url = 'http://test.ir/'
  content = s.get(url).content
  tree = html.fromstring(content)
  print [e.text_content() for e in tree.xpath('//div[@class="grouptext"]/text()[not(self:div)]')]
  </code></pre>
  
  <p>As you can see in the picture I want the <em>selected</em> part:
  <img src="https://i.stack.imgur.com/FV4rb.png" alt="enter image description here"></p>
  
  <p>When I use</p>
  
  <pre><code>print [e.text_content() for e in tree.xpath('//div[@class="grouptext"]')]
  </code></pre>
  
  <p>The result shows me the selected part <em>and</em> the content of <code>&lt;div class="grouptext"&gt;</code> as well.</p>