protected IEnumerable<Customer> ParseXml(XDocument doc) { var result = new List<Customer>(); XNamespace ns = NAMESPACE_CUSTOMER; var customers = doc.Root.Element(ns + "Customers").Elements(ns + "Customer"); foreach (var customer in customers) { var customerRecord = new Customer(); var fields = customer.Elements(); foreach (var field in fields) { var fieldId = field.Name.LocalName; var caption = field.Attribute("FieldCaption").Value; var value = field.Value; customerRecord.AddField(fieldId, caption, value); } result.Add(customerRecord); } return result; }