[lxml-dev] Text obscured by subelement

Stefan Behnel stefan_ml at behnel.de
Mon Aug 25 04:36:29 CEST 2008


Piet van Oostrum wrote:
>>>>>> John J Lee <jjl at pobox.com> (JJL) wrote:
>> JJL> doc = fromstring('<doc>text1<b>text2</b>text3<b>text4</b>text5</doc>')
>> JJL> b1, b2 = doc.getchildren()
>> JJL> print doc.text + b1.tail + b2.tail
> 
> print doc.text+''.join(c.tail for c in doc.getchildren())


print doc.text+''.join(c.tail for c in doc)


Stefan


More information about the lxml-dev mailing list