Greetings! Here is the problem, as clearly as I can state it: I want to take an xml document, split an element out of it, and use that element as the root of a new document, AND preserve the original document's namespace definitions in the new document. # --- Test 1 --- # tree1 = etree.ElementTree(etree.fromstring('<root xmlns="ns1"><element>boo</element></root>')) print tree1.getroot().nsmap print etree.tostring(tree1.getroot()) tree2 = etree.ElementTree(tree1.getroot().find('{ns1}element')) print tree2.getroot().nsmap print etree.tostring(tree2.getroot()) # --- Test 2 --- # nsdict = {'pre':'ns1'} tree1 = etree.ElementTree(etree.fromstring('<root xmlns="ns1"><element>boo</element></root>')) print tree1.getroot().nsmap print etree.tostring(tree1.getroot()) tree2 = etree.ElementTree(tree1.getroot().xpath('//pre:element', nsdict)[0]) print tree2.getroot().nsmap print etree.tostring(tree2.getroot()) # --- Test 3 --- # nsdict = {'pre':'ns1'} tree1 = etree.ElementTree(etree.fromstring('<pre:root xmlns:pre="ns1"><pre:element>boo</pre:element></pre:root>')) print tree1.getroot().nsmap print etree.tostring(tree1.getroot()) tree2 = etree.ElementTree(tree1.getroot().xpath('//pre:element', nsdict)[0]) print tree2.getroot().nsmap print etree.tostring(tree2.getroot()) In each of the three tests above, the root element of tree2 does indeed contain an nsmap with the correct values, but they are not being written out during reserialization. Is there any to fix this, other than manually adding the definitions as simple attributes just before saving the new document?