linq to xml 初学 -- 查询语法

初学linq  to xml,很方便

string path = ch.GetConfigFile("")+ "SpeedDial.xml";
        var sdDoc = XDocument.Load(path);
            

            //linq to xml

       var query = from resource in sdDoc.Descendants("item")
                        where (int)resource.Attribute("parentId") == 0
                        select new
                        {
                            Sn=resource.Element("sn").Value,
                            Name=resource.Element("name").Value,
                            Icon=resource.Element("icon").Value
                        };

 

posted @ 2018-01-17 12:11  韩梦芫  阅读(121)  评论(0编辑  收藏  举报