That is, all text and subtags, without the tag of an element itself?
Having
<p>blah <b>bleh</b> blih</p>
I want
blah <b>bleh</b> blih
element.text returns "blah " and etree.tostring(element) returns:
<p>blah <b>bleh</b> blih</p>
ElementTree works perfectly, you have to assemble the answer yourself. Something like this...
"".join( [ "" if t.text is None else t.text ] + [ xml.tostring(e) for e in t.getchildren() ] )
Thanks to JV amd PEZ for pointing out the errors.
Edit.
>>> import xml.etree.ElementTree as xml
>>> s= '<p>blah <b>bleh</b> blih</p>\n'
>>> t=xml.fromstring(s)
>>> "".join( [ t.text ] + [ xml.tostring(e) for e in t.getchildren() ] )
'blah <b>bleh</b> blih'
>>>
Tail not needed.