title: XPath select elements with specific attribute value?
body: <p>I'm having problems selecting nodes with XPath. I'll show the example, xml file is shortened due to the extensive amount of data in the real one:</p>
  
  <p>This is the subset of the XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;design xmlns="namespace_hidden" createddate="2012-12-07" createdby="User" name="New   Design"&gt;
    ...
    &lt;variables&gt;
    &lt;measurements&gt;
      &lt;measurement name="Measurement001"&gt;
        &lt;sample name="1"&gt;
          &lt;position&gt;[0,0]&lt;/position&gt;
          &lt;variables&gt;
            &lt;qualitative name="bId"&gt;
              &lt;class&gt;2193&lt;/class&gt;
            &lt;/qualitative&gt;
          &lt;/variables&gt;
        &lt;/sample&gt;
        ...
        &lt;sample name="4"&gt;
          &lt;position&gt;[3,0]&lt;/position&gt;
          &lt;variables&gt;
            &lt;qualitative name="Q2"&gt;
              &lt;class&gt;V0&lt;/class&gt;
            &lt;/qualitative&gt;
            &lt;qualitative name="Q3"&gt;
              &lt;class&gt;V2&lt;/class&gt;
            &lt;/qualitative&gt;
            &lt;qualitative name="Q4"&gt;
              &lt;class&gt;V1&lt;/class&gt;
            &lt;/qualitative&gt;
            &lt;quantitative name="Q5"&gt;
              &lt;unit&gt;Percent&lt;/unit&gt;
              &lt;value&gt;8&lt;/value&gt;
            &lt;/quantitative&gt;
          &lt;/variables&gt;
        &lt;/sample&gt;
      &lt;/measurement&gt;
      &lt;measurement name="Measurement002"&gt;
          ..
      &lt;/measurement&gt;
      ...
     &lt;/measurements&gt;
  &lt;/design&gt;
  </code></pre>
  
  <p>Now, im trying to select all variables under a specific sample, under a specific measurement.</p>
  
  <p>This is the querying method I use:</p>
  
  <pre><code>// Creating the navigator
  var doc = new XPathDocument(xmlDoc[0]);
  var navigator = doc.CreateNavigator();
  
  // Creating the namespace manager:
  XmlNamespaceManager nsMan = null;
  if (navigator.NameTable != null) {
       nsMan = new XmlNamespaceManager(navigator.NameTable);
       nsMan.AddNamespace("y", xmlNs);
       nsMan.PushScope();
  }
  
  // Executing the query
  var iterator = navigator.Select(string.Format("/y:design/y:measurements/y:measurement[name='{0}']/y:sample[name={1}]/y:variables/y:qualitative", currentMeasurement.Name, currentSample.Name), nsMan);
  </code></pre>
  
  <p>When I use this query I get the first measurement and the first sample, so that works:</p>
  
  <pre><code>string.Format("/y:design/y:measurements/y:measurement[1]/y:sample[1]"
  </code></pre>
  
  <p>but if I use this query:</p>
  
  <pre><code>"/y:design/y:measurements/y:measurement[name='Measurement001']/y:sample[1]"
  </code></pre>
  
  <p>I dont get any results</p>
  
  <p>In desperation I have also tried different combinations of '' around the attribute values to no success. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>Best regards, and thanks for any help!
  Richard</p>