doc = etree.XML(XML_string)
nsmap = {}
for ns in doc.xpath('//namespace::*'):
    if ns[0]:
        nsmap[ns[0]] = ns[1]
doc.xpath('//prefix:element', namespaces=nsmap)
How do I use xml namespaces with find/findall in lxml?