c# linq to xml take one element of many



I have this code



List<Customer> customersList =
(
from e in XDocument.Load(file).Root.Elements("cust")
select new Customer
{
CustomerID = (int)e.Attribute("custid"),
FirstName = (string)e.Attribute("fname"),
LastName = (string)e.Attribute("lname"),
ShowsNumber = (int)e.Attribute("count_noshow"),
VisitNumber = (int)e.Attribute("count_resos"),
Cancellation = (int)e.Attribute("count_cancel"),

}).ToList();


as you see, I am extracting the attributes, but I have three (sometimes four) elements of phone I want to extract the first element of them.


I tried this:



(string)e.Elements


but I don't know what should I do now


could you help me please?


No comments:

Post a Comment