XElement xmlCustomers = new XElement("customers",
from c in listCustomers
select new XElement("customer",
new XElement("name", c.Name),
new XAttribute("city", c.City),
new XAttribute("country", c.Country)));

MemoryStream mem = new MemoryStream();
DataContractSerializer dc = new DataContractSerializer(typeof(XElement));
dc.WriteObject(mem, xmlCustomers);
