Hello,
given the following piece of code which replaces all A nodes in P with B:
>>> tree = etree.fromstring("<P><A/><A/></P>")
>>> l = tree.findall("A")
>>> first, last = tree.index(l[0]), tree.index(l[-1])
>>> tree[first : last + 1] = [ etree.Element("B") ]
>>> etree.tostring(tree)
'<P><B/></P>'
This code works, but it feels kind of ugly.
Is there a more elegant way to replace a slice of the list of children
(actually all children having the same name, but they always appear in a row)
with another list of elements and keeping the document order intact?
TIA, Markus