That is how to convert a List<T> to a XML
public string retrieveAccount()
{
//Service
IOrganizationService service = GetOrganization();
//Retrieve Accounts
Entity accounts = new Entity("account");
EntityCollection accountList = methods.retriveAllAccounts(service);
var xEle = new XElement("Accounts",
from account in accountList
select new XElement("Account",
new XAttribute("Name", account.Name),
new XAttribute("Telephone", account.Telephone),
new XAttribute("Celphone", account.Celphone),
new XAttribute("Email", account.Email),
new XAttribute("Address",account.Address),
new XAttribute("Number", account.Number),
new XAttribute("Location", account.Location)
));
return xEle.ToString();
}
No comments:
Post a Comment