def element_to_int(element, attribute=None):
    """Convert ``element`` object to int. If attribute is not given, convert ``element.text``.

    :param element: ElementTree element
    :param attribute: attribute name
    :type attribute: str
    :returns: integer
    :rtype: int
    """
    if attribute is not None:
        return int(element.get(attribute))
    else:
        return int(element.text)