title: Relative XPath node selection with C# XmlDocument
body: <p>Imagine the following XML document:</p>
  
  <pre><code>&lt;root&gt;
      &lt;person_data&gt;
          &lt;person&gt;
              &lt;name&gt;John&lt;/name&gt;
              &lt;age&gt;35&lt;/age&gt;
          &lt;/person&gt;
          &lt;person&gt;
              &lt;name&gt;Jim&lt;/name&gt;
              &lt;age&gt;50&lt;/age&gt;
          &lt;/person&gt;
      &lt;/person_data&gt;
      &lt;locations&gt;
          &lt;location&gt;
              &lt;name&gt;John&lt;/name&gt;
              &lt;country&gt;USA&lt;/country&gt;
          &lt;/location&gt;
          &lt;location&gt;
              &lt;name&gt;Jim&lt;/name&gt;
              &lt;country&gt;Japan&lt;/country&gt;
          &lt;/location&gt;
      &lt;/locations&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I then select the person node for Jim:</p>
  
  <pre><code>XmlNode personNode = doc.SelectSingleNode("//person[name = 'Jim']");
  </code></pre>
  
  <p>And now from this node with a single XPath select I would like to retrieve Jim's location node. Something like:</p>
  
  <pre><code>XmlNode locationNode = personNode.SelectSingleNode("//location[name = {reference to personNode}/name]");
  </code></pre>
  
  <p>Since I am selecting based on the personNode it would be handy if I could reference it in the select. Is this possible?.. is the connection there?</p>
  
  <p>Sure I could put in a few extra lines of code and put the name into a variable and use this in the XPath string but that is not what I am asking.</p>