def etree_strip_namespaces(element):
 retval = etree.Element(element.tag.rpartition('}')[(-1)])
 retval.text = element.text
 for a in element.attrib:
  retval.attrib[a.rpartition('}')[(-1)]] = element.attrib[a]
 for e in element:
  retval.append(etree_strip_namespaces(e))
 return retval

def etree_strip_namespaces ( element ) : retval = etree . Element ( element . tag . rpartition ( '}' ) [ ( - 1 ) ] ) retval . text = element . text for a in element . attrib : retval . attrib [ a . rpartition ( '}' ) [ ( - 1 ) ] ] = element . attrib [ a ] for e in element : retval . append ( etree_strip_namespaces ( e ) ) return retval
removes any namespace information form the given element recursively .