private static void ReadXML(string xml)
{
try
{
if (string.IsNullOrEmpty(xml)) return; // handle network errors
// we don't *need* these IDs if we're exiting, but I think it does no harm to check we received a valid response
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlNodeList nodes = doc.GetElementsByTagName("DB");
if (nodes.Count == 1 && nodes[0].Attributes != null && nodes[0].Attributes.Count == 2)
{
RecordId = int.Parse(nodes[0].Attributes["Record"].Value);
SecretNumber = int.Parse(nodes[0].Attributes["Verify"].Value);
}
else
{
throw new XmlException("Error parsing XML returned from UsageStats server");
}
}
catch (Exception ex)
{
if (ex is XmlException)
throw;
throw new XmlException("Error parsing XML returned from UsageStats server", ex);
}
}