python lxml: how to get text from a element which has a child element
<p>I want to extract sometext from the html code, but the following doesn't r
eturn sometext, instead it return "\n". So how to get sometest?</p>

<pre><code>a=html.fromstring("""
&lt;p class="clearfix"&gt;
&lt;i class="xueli"&gt;&lt;/i&gt;
sometext
&lt;/p&gt;
""")
a.find(".//i").getparent().text
</code></pre>

<p>Instead of <code>.text</code>, use <code>text_content()</code> method:</p>

<pre><code>In [5]: a.find(".//i").getparent().text_content().strip()
Out[5]: 'sometext'
</code></pre>

<p>Or, you can get to the <em>following text sibling</em> of the <code>i</code> element:</p>

<pre><code>In [6]: a.xpath(".//i/following-sibling::text()")[0].strip()
Out[6]: 'sometext'
</code></pre>

python lxml