Linq读取XML
<root> <level1 name="A"> <level2 name="A1" /> <level2 name="A2" /> </level1> <level1 name="B"> <level2 name="B1" /> <level2 name="B2" /> </level1> <level1 name="C" /></root>
A A1 A2 B B1 B2 C
XDocument xdoc = XDocument.Load("data.xml"));var lv1s = from lv1 in xdoc.Descendants("level1") select lv1.Attribute("name").Value;foreach (var lv1 in lv1s){ result.AppendLine(lv1); var lv2s = from lv2 in xdoc...???}
婷婷同学_