private void bOK_Click(object sender, EventArgs e) { XDocument doc = new XDocument(); XElement root = new XElement(AutoRankManager.TagName); foreach (TreeNode node in treeData.Nodes) { ActionNode anode = (ActionNode)node; if (anode.FromRank == null || anode.ToRank == null) { continue; } Criterion crit = new Criterion { FromRank = anode.FromRank, ToRank = anode.ToRank, Condition = ExportConditions(anode) }; root.Add(crit.Serialize()); } doc.Add(root); doc.Save(Paths.AutoRankFileName); Application.Exit(); }