Dorkinniliova
New Member
\[code\]<Employees> <Employee> <EmpId>1</EmpId> <Name>Sam</Name> <Sex>Male</Sex> <Phone Type="Home">423-555-0124</Phone> <Phone Type="Work">424-555-0545</Phone> </Employee></Employees>private void Window_Loaded(object sender, RoutedEventArgs e) { emplyeeDetails = XDocument.Load(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + "\\LinqToXml\\Xmls\\" + "Employees.xml"); var emplyees = from emp in emplyeeDetails.Descendants("Employee").Take(10) orderby emp.Element("EmpId").Value ascending select new { Id = emp.Element("EmpId").Value, Name = emp.Element("Name").Value, Sex = emp.Element("Sex").Value, WorkPhone=emp.Element("Phone").Attribute("Type").Value, HomePhone = emp.Element("Phone").Attribute("Type").Value, }; DgrdEmployeeDetails.ItemsSource = emplyees.ToList(); }\[/code\]Using above code i can get the result below.
But i need the column(WorkPhone) value 424-555-0545 instead of Home and the column(HomePhone) value 423-555-0124 instead of Home. What should i do for that ?