I have the following HTML markup and I'd like to get the English description as plain text out of this snippet - without the "English, and without any tags":
from lxml import etree
html = '''
<td class="description">
<p><b>English:</b> Ulm, Germany, old town with Münster, city wall and Metzgerturm, as seen from the south bank of the river Danube.</p>
<p><b>Deutsch:</b> Ulm, Ansicht der Altstadt vom rechten Donauufer aus. Abgebildet ist das Donauschwabenufer, von der Altstadt sind erkennbar: Das dominante Münster mit Hauptturm, Schiff und zwei Chortürmen; unterhalb des Hauptturms des Münsters zwei Giebel, die zur historischen Krone gehören (linker Giebel größtenteils von Bäumen verdeckt); die Spitze der neuen, gläsernen Stadtbibliothek von Gottfried Böhm; weiter rechts zwei Giebel des Rathauses (gelb-braun); am rechten Rand der Metzgerturm als Teil der Stadtbefestigung.</p>
</td>
'''
tree = etree.fromstring(html)
for el in tree.xpath('//td[contains(concat(" ", normalize-space(@class), " "), " description ")]/div|p'):
print etree.tostring(el)
With this script I get the single paragraphs including all tags, but I'm stuck there ... The paragraphs may be DIVs, as well; therefore I've used div|p inside the xpath.
The lxml solution should also work with DIV containers like this:
<td class="description">
<div class="description mw-content-ltr et" dir="ltr" lang="et" style=""><span class="language et" title=""><b>Eesti:</b></span> Olen loonud selle pildi, kui ma nägin arutelu uue Wiki logo.</div>
<div class="description mw-content-ltr en" dir="ltr" lang="en" style=""><span class="language en" title=""><b>English:</b></span> "Prototype" for new Wiktionary Logo</div>
</td>