Suppose I have an XML string:
<A>
    <B foo="123">
        <C>thing</C>
        <D>stuff</D>
    </B>
</A>
and I want to insert a namespace of the type used by XML Schema, putting a prefix in front of all the element names.
<A xmlns:ns1="www.example.com">
    <ns1:B foo="123">
        <ns1:C>thing</ns1:C>
        <ns1:D>stuff</ns1:D>
    </ns1:B>
</A>
Is there a way to do this (aside from brute-force find-replace or regex) using lxml.etree or a similar library?