C#XML数据库加载

时间:2018-11-04 17:43:50

标签: c# xml database treeview

我正在构建一个设计经理程序。该程序从XML database运行。我正在将数据加载到树视图中,然后可以在列表视图中显示详细数据。

我拥有的是:

XDocument xdoc = XDocument.Load("XML Template.xml");

            var CustomerList = from q in xdoc.Descendants("Customer")
                         select new
                         {
                             Customer = q.Element("Name").Value
                         };
            //add all the customers as top nodes to the treeview
            foreach (var assemblyList in CustomerList)
            {
                // get all the assembly numbers under that customer name.
                // add node to the tree view under the customer node.
                foreach (var partlist in assemblyList)
                {
                    // get all of the parts under that assembly number
                    // Add parts to the tree view under the aseembly node.
                    foreach (var file in partlist)
                    {
                        //add the data to another view
                    }
                }
            }

我似乎找不到用LINQ或System.xml编码这种结构的好方法。

1 个答案:

答案 0 :(得分:0)

我找到了使用嵌套循环的解决方案。可能不漂亮,但可以!

l