title: C# Get XML element value using XmlDocument
body: <p>Trying to retrieve the value of Rank in the XML file example below...
  the path i'm passing works fine wit the SelectNodes method, except when i add the attribute to the path then the code will skip the foreach loop</p>
  
  <p>appreciate any help on how to solve this.
  in addition i'm looking for one value of the Rank element and its a based on specific attributes of Sub ID and Rank ID so there is no need for the loop but that's the only way i know</p>
  
  <p>XML File:
  <i></p>
  
  <pre><code>&lt;Model&gt;
  
  &lt;BookStore&gt;
      &lt;Book&gt;
        &lt;Sub ID="Science"&gt;
          &lt;Rank ID="Chemistry"&gt;Value1&lt;/Rank&gt;
          &lt;Rank ID="Physics"&gt;Value2&lt;/Rank&gt;
        &lt;/Sub&gt;
      &lt;/Book&gt;
  &lt;/BookStore&gt;
  
  &lt;/Model&gt;
  </code></pre>
  
  <p></i></p>
  
  <p>C# Code:</p>
  
  <pre><code>var myDoc = new XmlDocument();
  myDoc.Load(MapPath("myXML.xml"));
  
  XmlNodeList rankList = myDoc.SelectNodes("/Model/BookStore/Book/Sub[@ID='Science']/Rank");  // Science can be any other variable
  foreach (XmlNode myRankNode in rankList)
  {
      if (myRankNode.Attributes["ID"].Value.ToString() == "Physics") // Physics can be any other variable
      {
          myValue = myRankNode.InnerText;
      }
  
  }
  </code></pre>