Xml Значение атрибутов требует двойных кавычек вокруг таких значений, как
См. xml решение linq ниже:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication4
{
class Program
{
const string FILENAME = @"c:\temp\test.xml";
const string FILENAME1 = @"c:\temp\test1.xml";
const string FILENAME2 = @"c:\temp\test2.xml";
static void Main(string[] args)
{
XDocument doc = XDocument.Load(FILENAME);
XDocument doc1 = XDocument.Load(FILENAME1);
XDocument doc2 = XDocument.Load(FILENAME2);
var joins = (from d in doc.Descendants("person")
join d1 in doc1.Descendants("person") on (int)d.Attribute("id") equals (int)d1.Attribute("id")
join d2 in doc2.Descendants("person") on (int)d.Attribute("id") equals (int)d2.Attribute("id")
select new { d = d, d1 = d1, d2 = d2 }
).ToList();
string ident = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> <person></person>";
XDocument outputXml = XDocument.Parse(ident);
XElement persons = outputXml.Root;
foreach (var join in joins)
{
XElement person = XElement.Parse(join.d.ToString());
person.Add(XElement.Parse(join.d1.Element("phone").ToString()));
person.Add(XElement.Parse(join.d2.Element("country").ToString()));
persons.Add(person);
}
}
}
}