def get_template_from_xml_file(xml_file):
    """Return the best matching template from an xml file

    Parameters
    ----------
    xml_file: str
        path to the xml file you wish to extract information from

    Returns
    -------
    template_params: dict
        dictionary of the best matching template parameters
    """
    from glue.ligolw import ligolw
    from glue.ligolw import lsctables
    from glue.ligolw import utils as ligolw_utils
    xmldoc = ligolw_utils.load_filename(xml_file, contenthandler=lsctables.
        use_in(ligolw.LIGOLWContentHandler))
    table = lsctables.SnglInspiralTable.get_table(xmldoc)
    template_params = {'mass_1': table[0].mass1, 'mass_2': table[0].mass2,
        'spin_1z': table[0].spin1z, 'spin_2z': table[0].spin2z, 'gps_time':
        table[0].end_time + 10 ** -9 * table[0].end_time_ns, 'ifo': [],
        'channel': []}
    for row in table:
        template_params['ifo'].append(row.ifo)
        template_params['channel'].append(row.channel)
    return template_params
