import re


def _xml_del_ns(xml):
    """A helper function that strips vcloud namespaces from xml text.
    This is used because sometimes the vcloud namespace is used, other 
    times it is not. Befuddling.""" 

    try:
        p = re.compile("xmlns=*[\"\"][^\"\"]*[\"\"]")
        allmatches = p.finditer(xml)
        for match in allmatches:
            xml = xml.replace(match.group(), "")
    except Exception as e:
        raise Exception(e)
    if "xmlns:vcloud" in xml:
        xml = xml.replace("vcloud:", "")
    xml = xml.replace(" xmlns:vcloud=\"http://www.vmware.com/vcloud/v1.5\"", "")
    return xml