private void LoadNode(XmlNode parent, ItemCollection items, CategoricalTreeViewItem parentItem) { foreach (XmlNode child in parent) { if (child.NodeType == XmlNodeType.Element && child.Name == "node") { string tmp = child.Attributes["range"].Value; string name = child.Attributes["name"].Value; string tmp2 = tmp.Substring(1, tmp.Length - 2); int tmpIndex = tmp2.IndexOf('-'); int min, max; int.TryParse(tmp2.Substring(0, tmpIndex), out min); int.TryParse(tmp2.Substring(tmpIndex + 1), out max); CategoricalTreeViewItem c = new CategoricalTreeViewItem(0, 0, parentItem); c.UpdateInfo(min, max, name); items.Add(c); if (child.HasChildNodes) { LoadNode(child, c.Items, c); } } } }