title: How to get attribute value using LINQ to XML?
body: <pre><code>&lt;Employees&gt;
    &lt;Employee&gt;
      &lt;EmpId&gt;1&lt;/EmpId&gt;
      &lt;Name&gt;Sam&lt;/Name&gt;
      &lt;Sex&gt;Male&lt;/Sex&gt;
      &lt;Phone Type="Home"&gt;423-555-0124&lt;/Phone&gt;
      &lt;Phone Type="Work"&gt;424-555-0545&lt;/Phone&gt;
    &lt;/Employee&gt;
  &lt;/Employees&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>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></pre>
  
  <p>Using the code above, I can get the result below:
  <img src="https://i.stack.imgur.com/J9IvU.png" alt="enter image description here"></p>
  
  <p>But I need the column <code>WorkPhone</code>'s value <code>424-555-0545</code> instead of <code>Home</code> and the column <code>HomePhone</code>'s value <code>423-555-0124</code> instead of <code>Home</code>. </p>
  
  <p>What should I do for that?</p>