http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument
I would thoroughly recommend using XDocument aka LINQ to XML. It's much simpler to create documents and process them.
If you're using .NET version 3.0 or lower, you have to use XmlDocument aka the classic DOM API.
XmlDocument is great for developers who are familiar with the XML DOM object model. It's been around for a while, and more or less corresponds to a W3C standard. It supports manual navigation as well as XPath node selection.
XDocument powers the LINQ to XML feature in .NET 3.5. It makes heavy use of IEnumerable<> and can be easier to work with in straight C#.
Both document models require you to load the entire document into memory (unlike XmlReader for example).
http://stackoverflow.com/questions/747554/populate-xdocument-from-string
http://stackoverflow.com/questions/1879395/how-to-generate-a-stream-from-a-string
пространство имён: System.Xml;
Класс XmlDocument
Сборка: System.Xml.dll
Метод:
Load(Stream) // Загружает XML-документ из указанного потока.
Load(string) // Загружает XML-документ из указанного URL-адреса.
Load(TextReader) // Загружает XML-документ из указанного TextReader
Load(XmlReader) // Загружает XML-документ из указанного XmlReader.
Метод:
LoadXml(string) // парсит строку с XML-контентом, XmlException
var doc = new XmlDocument();
doc.LoadXml(@"<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>");
http://stackoverflow.com/questions/956749/how-can-i-transform-xml-into-a-liststring-or-string
http://stackoverflow.com/questions/10211470/how-can-i-order-a-liststring
http://stackoverflow.com/questions/17043663/how-to-serialize-a-listt-into-xml
/*
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());
}
}