def get_element_attribute_or_empty ( element , attribute_name ) : return element . attributes [ attribute_name ] . value if element . hasAttribute ( attribute_name ) else ""
getattribute empty xml in python
def get_element_attribute_or_empty(element, attribute_name):
    """

    Args:
        element (element): The xib's element.
        attribute_name (str): The desired attribute's name.

    Returns:
        The attribute's value, or an empty str if none exists.

    """
    return element.attributes[attribute_name].value if element.hasAttribute(attribute_name) else ""