как считать данные в формате XML из файла в память на C# |
Разработка на C# под linux,
http://rsdn.ru/forum/dotnet/6433224.all |
/*
http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument
http://stackoverflow.com/questions/747554/populate-xdocument-from-string
http://stackoverflow.com/questions/956749/how-can-i-transform-xml-into-a-liststring-or-string
http://stackoverflow.com/questions/19102021/how-to-reverse-a-generic-list-without-changing-the-same-list
http://stackoverflow.com/questions/17043663/how-to-serialize-a-listt-into-xml
http://stackoverflow.com/questions/12956454/how-to-replace-elements-in-one-xdocument-with-elements-from-another-xdocument
http://stackoverflow.com/questions/268671/best-way-to-convert-ilist-or-ienumerable-to-array
http://stackoverflow.com/questions/4533609/how-to-get-xml-as-string-from-xdocument
*/
using System;
using System.Xml.Linq; // add System.Xml.Linq.dll to references
using System.Linq;
class MainClass
{
public static void Main (string[] args)
{
//
var doc = XDocument.Parse(@"<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>");
var list = doc.Root.Elements("li")
.Select(element => element.Value)
.ToList();
var reversed_list = list.AsEnumerable().Reverse();
XElement xmlElements = new XElement("ul", reversed_list.Select(i => new XElement("li", i)));
doc.Root.ReplaceWith(xmlElements);
System.Console.Write(doc.ToString());
}
}