XML序列化的用法大致如下:
//xml序列化到test.xml文件中
List<string> inputList = new List<string>() { "潮流时尚公子","http://gz168168.taobao.com"}; using (FileStream fsWriter = new FileStream(@"test.xml",FileMode.Create,FileAccess.Write)) { XmlSerializer xs = new XmlSerializer(typeof(List<string>)); xs.Serialize(fsWriter, inputList); }//从test.xml文件中反序列化出来
List<string> outputList = new List<string>(); using (FileStream fsReader = new FileStream(@"test.xml",FileMode.Open,FileAccess.Read)) { XmlSerializer xs = new XmlSerializer(typeof(List<string>)); outputList = xs.Deserialize(fsReader) as List<string>; }https://blog.csdn.net/wyc_ht/article/details/8659248
https://blog.csdn.net/stwuyiyu/article/details/51190548