def xml_to_dict(root, prefix=None, depth=1, diction=None):
    ret = diction if diction is not None else dict()
    for child in root:
        val = testXMLValue(child)
        # skip values that are empty or None
        if val is None or val == '':
            if depth > 1:
                ret = xml_to_dict(child,prefix=prefix,depth=(depth-1),diction=ret)
            continue

        key = format_string(child.tag.split('}')[-1])

        if prefix is not None:
            key = prefix + key

        ret[key] = val
        if depth > 1:
            ret = xml_to_dict(child,prefix=prefix,depth=(depth-1),diction=ret)

    return ret
Recursively iterates through an xml element to convert each element in the tree to a (key,val). Where key is the element
dataset/ETHPy150Open geopython/OWSLib/owslib/util.py/xml_to_dict