把Collection转化为XML

前端之家收集整理的这篇文章主要介绍了把Collection转化为XML前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
IList<string> sources = sourceFileLocation.Split(semicolonSeparater,StringSplitOptions.RemoveEmptyEntries).ToList();
XElement satFiles = new XElement("Files",from f in sources
         select new XElement("File",f));
XDocument satDoc = new XDocument(
         new XDeclaration("1.0","UTF-8","yes"),satFiles);
string satFilePath = Path.Combine(new FileInfo(Assembly.GetEntryAssembly().Location).DirectoryName,@"Files.xml");
satDoc.Save(satFilePath);

猜你在找的XML相关文章