通过linq读取xml文件内容
#region 使用linq读取xml文件中的数据public static void GetOneReadXmlByLinq(){//XDocumentXDocument doc = XDocument.Load("C:/Users/Public/Desktop/stream1.xml");var account = (from xml in doc.Descendants("TAccount"
·
#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

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)