private void formTree(XMLElement root, ref TreeNode treeNodes) { foreach (var node in root.getNodesList()) { TreeNode newTreeNode = treeNodes.Nodes.Add(node.Name); newTreeNode.Tag = node; if (node.hasValue()) { newTreeNode.Nodes.Add(node.Value); } if (node is XMLElement) { formTree((node as XMLElement), ref newTreeNode); } } }