public List <Channel> GetChannelList() { List <Channel> channels = new List <Channel>(); try { foreach (XElement element in Doc.Element("settings").Element("channels").Elements("channel").ToList()) { channels.Add(new Channel(element.FirstAttribute.Value, element.Value)); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } return(channels); }