How to deserialize xml using Linq?

后端 未结 3 1179
梦谈多话
梦谈多话 2020-12-06 13:18

How can i deserialize this xml using Linq? I want to create List


  
    1
    

        
3条回答
  •  长情又很酷
    2020-12-06 14:06

    LINQ-to-XML is your answer.

    List steps = (from step in xml.Elements("Step")
                        select new Step()
                        {
                            Id = (int)step.Element("Id"),
                            Name = (string)step.Element("Name"),
                            Description = (string)step.Element("Description")
                        }).ToList();
    

    And a bit about doing the conversions from XML from Scott Hanselman

提交回复
热议问题