title: XPath: Selecting a node based on another nodes value
body: <p>I am trying to use a single XPath expression to select a node that has a child node which matches another node in the document.  </p>
  
  <p>A match would mean that <strong>ALL</strong> attributes of the node are the same.  So if a node was being compared with several attributes doing individual attribute comparisons would be unmaintainable.</p>
  
  <p><strong>As an example</strong> given the following:</p>
  
  <pre><code>&lt;Network&gt;
      &lt;Machines&gt;
          &lt;Machine Name = "MyMachine"&gt;
              &lt;Services&gt;
                   &lt;ServiceDetails Description="MyService" Executable="c:\Myservice.exe" DisplayName="My Service" Version="5"/&gt;
              &lt;/Services&gt;
          &lt;/Machine&gt;
          ...
      &lt;/Machines&gt;
      &lt;Services&gt;
          &lt;Service Name = "Service1"&gt;
              &lt;ServiceDetails Description="MyService" Executable="c:\Myservice.exe" DisplayName="My Service" Version="5"/&gt;
          &lt;/Service&gt;
          ...
      &lt;/Services&gt;
  &lt;/Network&gt;
  </code></pre>
  
  <p>I want to get the service node from Services based on the ServiceDetails listed under MyMachine.</p>
  
  <p>I thought it would look something like:</p>
  
  <pre><code>//Services/Service[ServiceDetails = //Machines/Machine[@Name='MyMachine']/ServiceDetails]
  </code></pre>
  
  <p>but it doesn't seem to work.  I suspect the '=' operator isn't handling the node comparison correctly.  I think there are some XPath 2.0 Methods that might work but I am using .NET 4.0 (System.XML namespace) I do not know if I can use them.  If XPath 2.0 methods would help here I would really appreciate an explanation on how to use them in .Net 4.0.</p>
  
  <p>Thanks</p>