If the string starts with a known prefix in nsmap, replace it by full URI

    :param nsmap: Dictionary of prefix -> uri of namespace
    :param string: String in which to replace the namespace
    :return: Expanded string with no namespace

def expand_namespace(nsmap, string):
    """ If the string starts with a known prefix in nsmap, replace it by full URI

    :param nsmap: Dictionary of prefix -> uri of namespace
    :param string: String in which to replace the namespace
    :return: Expanded string with no namespace
    """
    for ns in nsmap:
        if isinstance(string, str) and isinstance(ns, str) and string.startswith(ns+":"):
            return string.replace(ns+":", nsmap[ns])
    return string