/// <summary> /// Gets the main element. /// </summary> /// <param name="xnod">The XML node.</param> /// <param name="topicsNames">The topics names.</param> /// <param name="topic">The topic.</param> /// <returns>Main element of the XML</returns> private static XmlElement GetMainElement(XmlNode xnod, SortedDictionary <Guid, string> topicsNames, Topic topic) { XmlElement mainElementName = null; if (xnod.NodeType != XmlNodeType.Element) { return(null); } if (xnod.Name == "topic") { if (!IOHelpers.IsGuid(xnod.Attributes["id"].Value)) { MessageBox.Show("GUID of the topic is invalid", "Invalid GUID!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { topic.TopicsGuid = new Guid(xnod.Attributes["id"].Value); if (!topicsNames.ContainsKey(topic.TopicsGuid)) { return(null); } topic.TopicsTitle = topicsNames[topic.TopicsGuid]; xnod = xnod.FirstChild; mainElementName = xnod as XmlElement; return(mainElementName); } } foreach (XmlNode xnodWorking in xnod.ChildNodes) { GetMainElement(xnodWorking, topicsNames, topic); } return(null); }