Zero Piraeus wrote:
>> You can try this:
>>
>>root = etree.parse(...).getroot()
>>new_root = etree.Element(root.tag, root.attrib)
>>new_root[:] = root[:]
>>
>> Note, however, that this will not copy root-level PIs or internal DTD
>> subsets.
>> But you can copy PIs and comments by hand
:
> > I want to remove an unused namespace declaration from the root element
> > of an ElementTree in lxml.
>
> > [...] I'm reduced to sticking the output through str.replace() ...
> > which is somewhat inelegant.
>
> And also a bit error prone (unless you are sure the replaced string really
> onl
Zero Piraeus wrote:
> I want to remove an unused namespace declaration from the root element
> of an ElementTree in lxml.
>
> There doesn't seem to be any documented way to do this, so at the
> moment I'm reduced to sticking the output through str.replace() ...
> which is somewhat inelegant.
And