Hi,
And what's the intention of discarding tail anyway?
As documented, it's only discarded at the root level where any tail text isn't allowed anyway (except for whitespace).
But the tail is not really discarded. Instead, the tail of the current node is appended to the tail of the inserted node; it merely moves from one node to the next.
I probably should mention that the "when adding to the root level" doesn't seem to work either. In the example, <p> would be the root level but tail is merely moved, and the exact same thing happens deeper down: s = "<foo><p>This is <b>bold</b> and this is italic text.</p></foo>" leads to
lxml.etree.tostring(xml) b'<foo><p>This is <b>bold</b><i>italic</i> text. and this is </p></foo>'
Cheers, Jens -- Jens Tröger http://savage.light-speed.de/