title: loop through infopath 2010 repeating section and display data in reverse order using C#
body: <p>I have a form created in InfoPath 2010 with c# code behind.  The purpose of this form is to be a running log for issues we deal with here.  The C# is being used to generate a very specifically formatted email.  The body of this email needs to show the items from the repeating field in reverse order (newest on top).  My first issues were trying to find a way to get the data from the repeating sections to be populated to the email body at all.  I was finally able to find this foreach loop that successfully printed the data in standard order. </p>
  
  <pre><code>foreach (XPathNavigator node in runningLogTable)
  {
      logEntry = node.SelectSingleNode("@my:entry", this.NamespaceManager).Value;
      logTime = node.SelectSingleNode("my:CurrentTime", this.NamespaceManager).Value;
      sb.Append(convertTime(logTime) + "\n");
      sb.Append(logEntry + "\n\n");
  }
  </code></pre>
  
  <p>Source: <a href="https://stackoverflow.com/questions/11477723/infopath-repeating-table-get-field-from-current-row">Infopath repeating table - get field from current row</a></p>
  
  <p>Incidentally, this loop is inside of a stringBuilder function.  My question is, how do I do this in reverse order?<br>
  I've been Googling this for days and I don't know if I just don't know the correct terminology or what, but needless to say, I have been unable to locate a solution that works.  I know there has got to be a simple solution that I'm just not seeing.</p>