Loop through Repeating Group w/subgroups - InfoPath Dev
in

InfoPath Dev

Loop through Repeating Group w/subgroups

Last post 12-07-2006 11:16 AM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-07-2006 08:22 AM

    Loop through Repeating Group w/subgroups

    I am using the following to get the value from the top level of my group, how to I loop through sub and sub-sub groups (the number of which changes)?

          
    Dim oNodeList As IXMLDOMNodeList
    Dim oNode As IXMLDOMNode
    Dim oField As IXMLDOMNode
    oNodeList = thisXDocument.DOM.selectNodes("my:myFields/my:ProjEstimate/my:WBSSummary")
    If (oNodeList.length > 0) Then
    For Each oNode In oNodeList
    If (oNode.nodeType = DOMNodeType.NODE_ELEMENT) Then
    oField = oNode.selectSingleNode("my:WBSNum")
    thisXDocument.UI.Alert(oField.text)
    End If
    Next
    End If

    TIA
    Dean
    Dean
    Charlotte, NC
  • 12-07-2006 11:16 AM In reply to

    Re: Loop through Repeating Group w/subgroups

    Hi Dean,
    One easy way is to use recursion. Create a function for the code in your If block. Call this function and pass it the oNodeList element. Then, add an Else If block parallel to the NODE_ELEMENT check that includes a call to this function with the ONode as the parameter. Recursion means successively calling into the same function. Of course recursion is not a great coding practice because it can cause infinite recursion if you are not careful with conditions. In addition, it uses up a lot of stack space. However, it does result in the least amount of code. Good luck!
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.