def get_xml_data(xml_tree,tag,as_type=float,repeated=False):
    """ 
    Extract xml data as specified type
    
    If repeated = True, first occurrence of attribute is stored.
    Else, its last occurrence is stored.
    """    
    data = None
    for element in xml_tree.iter(tag=tag):
        data_as_str = element.text.split()
        if len(data_as_str)>1: data = [as_type(d_str) for d_str in data_as_str]
        else: data = as_type(data_as_str[0])
        if repeated: break
        
    if data is None: raise ValueError('xml data within tag %s not found'%tag)
    else: return data