Helper function. Lightweight test if response is an XML doc

def is_xml(text):
    """
    Helper function. Lightweight test if response is an XML doc
    """
    # BOM_UTF8 is an UTF-8 byte order mark which may precede the XML from an Exchange server
    bom_len = len(BOM_UTF8)
    if text[:bom_len] == BOM_UTF8:
        return text[bom_len:bom_len + 5] == b'<?xml'
    return text[:5] == b'<?xml'