LINQ query to parse content from XML to class

前端 未结 3 1146
广开言路
广开言路 2021-01-28 13:35

I have an xml from which I am trying to extract some information through LINQ query.
The format of the xml file looks like the following:


           


        
3条回答
  •  滥情空心
    2021-01-28 14:23

    I'm not sure I understood the question, but you can easily take element/attribute value inside LINQ to XML select statement:

    var EnumerableContent = from item in XElement.Load("file.xml").Elements("NextItem")
                  select new Extract() { name = item.Value, _id = (int)item.Attribute("id") }
    

提交回复
热议问题