DataTable dt = new DataTable(); dt.Columns.Add("name", typeof(string)); dt.Columns.Add("value", typeof(int)); dt.Columns.Add("para", typeof(string)); string filename = AppDomain.CurrentDomain.BaseDirectory + "DefaultStart.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); XmlNode xmlNode = xmlDoc.SelectSingleNode("DocumentElement"); string xmlData = xmlNode.InnerXml; //加载XML数据,,也可XElement.Load("文件名") var xdoc = XElement.Parse(xmlData); var m = (from mod in xdoc.Elements("Node") select new { //给DataTabel添加数据行 a = dt.Rows.Add(mod.Element("name").Value, mod.Element("value").Value, mod.Element("para").Value) }).ToList(); dataGridView1.DataSource = dt;