title: How to get XmlElement from XmlNodeList in C#?
body: <p>Below is sample of my XML file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;summary&gt;  
    &lt;testresult&gt;    
      &lt;result value="10" name="long"&gt;100&lt;/result&gt;
      &lt;result value="12" name="short"&gt;200&lt;/result&gt;
      &lt;result value="14" name="long"&gt;300&lt;/result&gt;
    &lt;/testresult&gt;
    &lt;testresult&gt;   
      &lt;result value="10" name="short"&gt;50&lt;/result&gt;
      &lt;result value="12" name="short"&gt;60&lt;/result&gt;
      &lt;result value="14" name="long"&gt;70&lt;/result&gt;
    &lt;/testresult&gt;
  &lt;/summary&gt;
  </code></pre>
  
  <p>I need to get attribute values for result elements.</p>
  
  <p>I done it using foreach loop as below.</p>
  
  <pre><code>XmlDocument xmlDoc = new XmlDocument();
  xmlDoc.Load(item.Value);
  XmlNodeList nodelist = xmlDoc.SelectNodes("//testresult");
  
  for (int i = 0; i &lt; nodelist.Count; i++)
  {
      foreach (XmlElement child in nodelist[i])
      {
          if (child.HasAttributes)
          {
              result.Add(child.Attributes["value"].Value); //This is working fine.
          }       
      }
  }
  </code></pre>
  
  <p><strong>My ultimate goal is to identify the name and get value if name = "long" only.</strong></p>
  
  <p>for that I need to get the value of <strong>name Attribute</strong>.
  I need to do that <strong>without using foreach loop</strong>. Any suggestion to achieve my task <strong>inside the for loop</strong> ?</p>
  
  <p>Thanks.</p>