我正在构建一个设计经理程序。该程序从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编码这种结构的好方法。
答案 0 :(得分:0)
我找到了使用嵌套循环的解决方案。可能不漂亮,但可以!
l