title: XPath "Counter" expression is not returning a valid number
body: <p>Is there a way to modify the following XPath expression to return the number of previous "like" elements? I need a relative count of the number of like nodes in a given branch (I think it's a branch...) This is being used in MS InfoPath:</p>
  
  <p><code>count(../preceding-sibling::*) + 1</code></p>
  
  <p>I believe that the structure of my sample XML prevents this from behaving as intended. You will note that all the "Count" values in my XML have the number <strong>1</strong>. The <code>DateRepeaterCounter</code> value should reset in a new <code>MasterRepeater</code> node and the <code>MasterRepeaterCounter</code> should reflect the overall number of <code>MasterRepeater</code> nodes.</p>
  
  <p>I have yet to overcome the learning curve with XPath.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;?mso-infoPathSolution solutionVersion="1.0.0.25" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Chris\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer3\e1d38b31bb224d94\manifest.xsf" ?&gt;&lt;?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?&gt;
  &lt;my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-09-07T14:19:10" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us"&gt;
  &lt;my:PrimarySection&gt;
      &lt;my:MasterRepeater&gt;
          &lt;my:MasterRepeaterCounter&gt;1&lt;/my:MasterRepeaterCounter&gt;
          &lt;my:DateSection&gt;
              &lt;my:DateRepeater&gt;
                  &lt;my:Date&gt;2012-09-12&lt;/my:Date&gt;
                  &lt;my:DateRepeaterCounter&gt;1&lt;/my:DateRepeaterCounter&gt;
              &lt;/my:DateRepeater&gt;
              &lt;my:DateRepeater&gt;
                  &lt;my:Date&gt;2012-09-13&lt;/my:Date&gt;
                  &lt;my:DateRepeaterCounter&gt;1&lt;/my:DateRepeaterCounter&gt;
              &lt;/my:DateRepeater&gt;
              &lt;my:DateRepeater&gt;
                  &lt;my:Date&gt;2012-09-14&lt;/my:Date&gt;
                  &lt;my:DateRepeaterCounter&gt;1&lt;/my:DateRepeaterCounter&gt;
              &lt;/my:DateRepeater&gt;
              &lt;/my:DateSection&gt;
      &lt;/my:MasterRepeater&gt;
      &lt;my:MasterRepeater&gt;
          &lt;my:MasterRepeaterCounter&gt;1&lt;/my:MasterRepeaterCounter&gt;
          &lt;my:DateSection&gt;
              &lt;my:DateRepeater&gt;
                  &lt;my:Date&gt;2012-09-15&lt;/my:Date&gt;
                  &lt;my:DateRepeaterCounter&gt;1&lt;/my:DateRepeaterCounter&gt;
              &lt;/my:DateRepeater&gt;
              &lt;my:DateRepeater&gt;
                  &lt;my:Date&gt;2012-09-16&lt;/my:Date&gt;
                  &lt;my:DateRepeaterCounter&gt;1&lt;/my:DateRepeaterCounter&gt;
              &lt;/my:DateRepeater&gt;&lt;my:DateRepeater&gt;
                  &lt;my:Date&gt;2012-09-17&lt;/my:Date&gt;
                  &lt;my:DateRepeaterCounter&gt;1&lt;/my:DateRepeaterCounter&gt;
              &lt;/my:DateRepeater&gt;
      &lt;/my:DateSection&gt;
      &lt;/my:MasterRepeater&gt;
  &lt;/my:PrimarySection&gt;
  &lt;/my:myFields&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT &amp; ANSWER</strong></p>
  
  <p>InfoPath was messing up the expression somehow... After entering the expression in one field and then copying it into another it stopped working correctly. Upon re-entering the epxression as formatted above, it resolved the issue. I will self answer when StackOverflow allows it. Thanks!</p>