title: How to get attribute value using SelectSingleNode?
body: <p>I am parsing a xml document, I need find out the gid (an attribute) value (3810). </p>
  
  <p>Based on <code>SelectSingleNode()</code>. I found it is not easy to find the attribute name and it's value. </p>
  
  <p>Can I use this method or must I switch to another way.</p>
  
  <p>Attached is my code.</p>
  
  <p>How can I use <code>book</code> obj to get the attribute value<code>3810</code> for <code>gid</code>. Thank you.</p>
  
  <p>My test.xml file as below</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" ?&gt;
  &lt;root&gt;
     &lt;VersionInfo date="2007-11-28" version="1.0.0.2" /&gt;
     &lt;Attributes&gt;
        &lt;AttrDir name="EFEM" DirID="1"&gt;
           &lt;AttrDir name="Aligner" DirID="2"&gt;
              &lt;AttrDir name="SequenceID" DirID="3"&gt;
                 &lt;AttrObj text="Slot01" gid="3810" unit="" scale="1" /&gt;
                 &lt;AttrObjCount value="1" /&gt;
             &lt;/AttrDir&gt;
           &lt;/AttrDir&gt;
        &lt;/AttrDir&gt;
     &lt;/Attributes&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I wrote the test.cs as below</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Sample
  {    
      public static void Main()
      {    
          XmlDocument doc = new XmlDocument();
          doc.Load("test.xml");
  
          XmlNode book;
          XmlNode root = doc.DocumentElement;
  
          book = root.SelectSingleNode("Attributes[AttrDir[@name='EFEM']/AttrDir[@name='Aligner']/AttrDir[@name='SequenceID']/AttrObj[@text='Slot01']]");
  
          Console.WriteLine("Display the modified XML document....");
          doc.Save(Console.Out);
      }
  }
  </code></pre>
  
  <p>[Update 06/10/2010]</p>
  
  <ol>
  <li><p>The xml file is a complex file. Included thousands of gids. But for each of Xpath, the gid is unique.</p></li>
  <li><p>I load the xml file to a TreeView control. <code>this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);</code>. When <code>treeView1_AfterSelect</code> event occurred, the <code>e.Node.FullPath</code> will return as a String Value.</p></li>
  <li><p>I parse the string Value <code>e.Node.FullPath</code>. Then I got the member of XPath Above. Then I tried to find which gid item was selected. </p></li>
  </ol>
  
  <p>I need find the gid value as a return value indeed.</p>