title: How to get specific attributes with values from an xml document using c# console?
body: <p>I have an xml document like below:</p>
  
  <pre><code>&lt;?xml version = "1.0"?&gt;
  &lt;Employees&gt;
      &lt;Employee Id="1" City="Seattle"&gt;
          &lt;EmployeeName&gt;Nancy Davolio&lt;/EmployeeName&gt;
          &lt;Country&gt;USA&lt;/Country&gt;
      &lt;/Employee&gt;
      &lt;Employee Id="2" City="Tacoma"&gt;
          &lt;EmployeeName&gt;Andrew Fuller&lt;/EmployeeName&gt;
          &lt;Country&gt;USA&lt;/Country&gt;
      &lt;/Employee&gt;
      &lt;Employee Id="3" City="Kirkland"&gt;
          &lt;EmployeeName&gt;Janet Leverling&lt;/EmployeeName&gt;
          &lt;Country&gt;USA&lt;/Country&gt;
      &lt;/Employee&gt;
  &lt;/Employees&gt;
  </code></pre>
  
  <p>From this file, I like to get displayed in the console only the EmployeeName for every employee with their tags. Below is how I tried to do so but it is showing only the opening and closing tag but not the value of EmployeeName.</p>
  
  <pre><code>static void Main(string[] args)
          {
  
  
              XmlTextReader reader = new XmlTextReader("D://test.xml");
              while (reader.Read())
              {
                  switch (reader.NodeType)
                  {
                      case XmlNodeType.Element: // The node is an element.
                          if (reader.Name == "EmployeeName")
                          {
                              Console.Write("&lt;" + reader.Name);
                              Console.WriteLine("&gt;");
  
                          }
                           break;
                      case XmlNodeType.Text: //Display the text in each element.
                           if (reader.Name == "EmployeeName")
                           {
                               Console.WriteLine(reader.Value);
                           }
  
                          break;
                      case XmlNodeType.EndElement: //Display the end of the element.
                          if (reader.Name == "EmployeeName")
                          {
                              Console.Write("&lt;/" + reader.Name);
                              Console.WriteLine("&gt;");
                          }
  
                          break;
                  }
              }
              Console.ReadLine();
  
  
  
          }
  </code></pre>
  
  <p>Any help, please!</p>