How to read a XML file and write into List<>?

后端 未结 5 1442
自闭症患者
自闭症患者 2020-12-09 05:09

I have a List<> which I have managed to write into file. Now I am trying to read the same file and write it back to List<>. Is there a

5条回答
  •  遥遥无期
    2020-12-09 05:47

    You can try this (using System.Xml.Linq)

    XDocument xmlDoc = XDocument.Load("yourXMLFile.xml");
    var list = xmlDoc.Root.Elements("id")
                               .Select(element => element.Value)
                               .ToList();
    

提交回复
热议问题