Я новичок в изучении возможностей Linq to XML, и недавно я обнаружил, что могу запрашивать XML как базу данных (сейчас я весьма очарован).
Мой вопрос: как я могу запросить XML-файл и сохранить результат в другом XML-файле?
string url = "employees.xml";
XElement employees= XElement.Load(url);
if (employees.Element("employee") != null)
{
var query = from f in employees.Element("employee").Elements("item").Take(10)
select new { Name = f.Element("name").Value, Surname= f.Element("surname").Value };
foreach (var feed in query)
{
//here... I like to write the result in a different xml file, I tried the
//common
doc.save("xmlout.xml");
}
}
Большое спасибо за вашу помощь,