#region 使用linq读取xml文件中的数据 public static void GetOneReadXmlByLinq() { //XDocument XDocument doc = XDocument.Load("C:/Users/Public/Desktop/stream1.xml"); var account = (from xml in doc.Descendants("TAccount") where xml.Element("IsDelete").Value == "N" && xml.Element("AccountName").Value == "张三" select new { AccountName = xml.Element("AccountName").Value, AccountPwd = xml.Element("AccountPwd").Value }).ToList(); foreach (var item in account) { Console.WriteLine(item.AccountName); Console.WriteLine(item.AccountPwd); } } #endregion