Given an XML node, extract a dictionary of attribute key-value pairs.
    Optional arguments:

    - prefix_key_char: if a character is given, the attributes keys
      in the resulting dictionary are prefixed with that character.

    - dict_constructor: the class used to create the resulting dictionary.
      Default is 'dict', but in DINGO, also DingoObjDict may be used.

def extract_attributes(element, prefix_key_char='@', dict_constructor=dict):
    """
    Given an XML node, extract a dictionary of attribute key-value pairs.
    Optional arguments:

    - prefix_key_char: if a character is given, the attributes keys
      in the resulting dictionary are prefixed with that character.

    - dict_constructor: the class used to create the resulting dictionary.
      Default is 'dict', but in DINGO, also DingoObjDict may be used.
    """
    result = dict_constructor()
    if element.properties:
        for prop in element.properties:
            if not prop:
                break
            if prop.type == 'attribute':
                try:
                    # First try with namespace. If no namespace exists,
                    # an exception is raised
                    result["%s%s:%s" % (prefix_key_char, prop.ns().name, prop.name)] = prop.content
                except:
                    result["%s%s" % (prefix_key_char, prop.name)] = prop.content
    return result