private static List<TreeNode> ParseElement(XElement parent)
        {
            List<TreeNode> tree = new List<TreeNode>();

            // Create a TreeNode for this node.
            TreeNode node = new TreeNode(parent.Name.LocalName);

            // Recurse.
            if (parent.HasElements)
            {
                foreach (XElement child in parent.Elements())
                {
                    // Parse child elements.
                    node.Children.AddRange(ParseElement(child));
                }
            }
            else
            {
                // Leaf-node.
                node.Value = parent.Value;
            }

            // Add this node to the tree.
            tree.Add(node);

            return tree;
        }
        private static string RenderTreeNode(TreeNode parent)
        {
            string html = "";
            bool leaf = false;
            string spanClass = "folder";

            if (parent.Children.Count == 0)
            {
                leaf = true;
                spanClass = "file";
            }

            // Create a TreeNode for this node.
            html += "<li><span class='" + spanClass + "'>" + parent.Name;
            if (leaf)
            {
                html += ": " + parent.Value;
            }
            html += "</span>";

            if (!leaf)
            {
                html += "\n<ul>\n";

                foreach (TreeNode child in parent.Children)
                {

                    // Render child elements.
                    html += RenderTreeNode(child);
                }

                html += "</ul>\n";
            }

            html += "</li>\n";

            return html;
        }