function [t0, fs, fc] = parseNIxml(datadir, filename)
% parseXml : Parse National-Instruments-produced XML file that accompanies raw
%            Ku-Band signal captures.
%
% INPUTS
%
% datadir ---- Full path to directory where XML file is stored
%
% filename --- Filename of XML file (sans .xml suffix).
%
%
% OUTPUTS
% 
% t0 ----- Timestamp of first sample expressed as a datetime in UTC.
%
% fs ----- Complex sampling rate (Hz)
%
% fc ----- Center frequency of capture (Hz)
% 

xml = readstruct([datadir '/' filename '.xml']);
[ac, bc] = xml.Cluster.Cluster.DBL;
if(ac(1).Name == "absolute timestamp")
  t0_LabView = ac(1).Val;
  LabView_epoch = datetime(1904,1,1,0,0,0);
  t0 = LabView_epoch + seconds(t0_LabView);
else
  error('Could not read initial sample absolute timestamp');
end
if(xml.Cluster.DBL(3).Name == "IQ Rate")
  fs = round(xml.Cluster.DBL(3).Val);
else
  error('Could not read IQ Rate');
end
[ac, bc] = xml.Cluster.Cluster.Cluster;
ac = bc.Cluster.DBL;
if(ac(1).Name == "center frequency")
  fc = ac(1).Val;
else
  error('Could not read center frequency');
end