title: xpath find value of current node
body: <p>I have several nodes with same Name='UPC' and I need to find the value of the current one.</p>
  
  <pre><code>&lt;XML&gt;
  &lt;Attribute&gt;
        &lt;Name&gt;UPC&lt;/Name&gt;
        &lt;Type&gt;ComplexAttr&lt;/Type&gt;
        &lt;Value&gt;Testing&lt;/Value&gt;
      &lt;/Attribute&gt;
      &lt;Attribute&gt;
        &lt;Name&gt;UPC&lt;/Name&gt;
        &lt;Type&gt;ComplexAttr&lt;/Type&gt;
        &lt;Value&gt;24a&lt;/Value&gt;
      &lt;/Attribute&gt;
  &lt;/XML&gt;
  </code></pre>
  
  <p><strong>Expected Output:</strong>
  It should pull the value from /Attribute/Value where Name='UPC' and Type = 'ComplexAttr'.</p>
  
  <p>On the first run = 'Testing' &amp;
  On the 2nd run the value should be = '24a' </p>
  
  <p>I'm trying to use the following code but it is not working. The value is null.</p>
  
  <pre><code>&lt;xsl:attribute name ="value"&gt;
      &lt;xsl:value-of select =".//Attribute[Type='ComplexAttr' and Name = 'UPC'][$i]/Value" /&gt;
  &lt;/xsl:attribute&gt;
  </code></pre>
  
  <p>where <strong>$i</strong> is the variable I'm using to loop through the above xml and it increments after each run. However, it only gives me the same value '<strong>Testing</strong>' (which is the first value) in every run. I have checked the value of the variable. It is changing every time it loops through. </p>
  
  <p>I have also tried using current() and position() like below but I'm getting null in this case.</p>
  
  <pre><code>&lt;xsl:value-of select =".//Attribute[Type='ComplexAttr' and Name = 'UPC'][current()]/Value" /&gt;
  
  &lt;xsl:value-of select =".//Attribute[Type='ComplexAttr' and Name = 'UPC'][position() = $i]/Value" /&gt;
  </code></pre>
  
  <p>Can someone help me out with this. Thanks in Advance.</p>