예제 #1
0
        private List <XmlTree> getItems(XElement root)
        {
            var items = new List <XmlTree>();

            foreach (var item in root.Elements())
            {
                var tree = new XmlTree();
                tree.Name  = item.Name.LocalName;
                tree.Items = getItems(item);
                tree.Value = item.Value;
                items.Add(tree);
            }
            return(items);
        }
예제 #2
0
        private string ParseXml(string xml)
        {
            var result = new XmlTree();
            var root   = XElement.Parse(xml);

            result.Name  = root.Name.LocalName;
            result.Items = getItems(root);
            result.Value = root.Value;

            string res = "";

            if (!result.Items.Any())
            {
                res = "<div class=\"value-row\"><div class=\"tag\"><p>" + result.Name + "</p></div><div class=\"value\"><p>" + getValue(result.Value) + "</p></div></div>";
            }
            else
            {
                res = "<div class=\"tree-row\"><span class=\"opened\"></span>&#60;" + result.Name + "&#62;<div class=\"inner\">" + getHtml(result.Items, 0) + "</div>&#60;/" + result.Name + "&#62;</div>";
            }

            return(res);
        }