Repeating table from XMLDataDoc - InfoPath Dev
in

InfoPath Dev

Repeating table from XMLDataDoc

Last post 08-31-2004 02:55 PM by Greg Collins. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-02-2004 02:05 PM

    Repeating table from XMLDataDoc

    I want to populate a repeating table from VB managed code from an XMLDataDocument.

    <table>
    <row><first>Tom</first><last>Smith</last></row>
    <row><first>Dick</first><last>Jones</last></row>
    <row><first>Harry</first><last>Johnson</last></row>
    </table>

    I would like the repeating table to look like this:
    Tom Smith
    Dick Jones
    Harry Johnson


    I tried variations of this:

    For Each XNode In XNodes
    thisXDocument.DOM.selectSingleNode("//my:first").text = XNode.InnerText.ToString
    thisXDocument.DOM.selectSingleNode("//my:last").text = XNode.InnerText.ToString
    End If

    The only thing that showed up was (the last one in the first row):

    Harry Johnson

    Do you have an example of how to do this? Thanks.

    Frank
  • 08-04-2004 06:29 PM In reply to

    Re: Repeating table from XMLDataDoc

    Your selectSingleNode() call is always grabbing the first row of the table. If you can guarantee that you will always have the same number of rows as you do XNodes, then you could use a variable to get you by:

    Dim iRow = 1
    For Each XNode In XNodes
    thisXDocument.DOM.selectSingleNode("//my:first[iRow]").text = XNode.InnerText.ToString
    thisXDocument.DOM.selectSingleNode("//my:last[iRow]").text = XNode.InnerText.ToString
    iRow = iRow + 1
    ...


    But if you are trying to actually create a new row in the table for each XNode that exists, that's a whole different scenario. In this case you would need to create new Elements and populate them, then insert them into the DOM.

    Let me know if this was enough to get you going, or if you need more help.

    Greg Collins [InfoPath MVP]
  • 08-04-2004 07:59 PM In reply to

    Re: Repeating table from XMLDataDoc

    Thanks Greg. I will not know the number of rows. I guess I could loop through the nodes and count them? I will give this a try and let you know. Thanks again.

    Regards,
    Frank

    Frank Solner
  • 08-15-2004 05:22 AM In reply to

    Re: Repeating table from XMLDataDoc

    Hey Greg. I did a lot of homework and still cannot get it to go. Could you provide an example of how to add rows to a repeating table from an XMLDataDocument. In other words, I want to add one row to the repeating table for each node in the XDD.

    Thanks,
    Frank

    Frank Solner
  • 08-18-2004 02:30 PM In reply to

    Re: Repeating table from XMLDataDoc

    I haven't forgotten you... I've just got a very busy week and haven't had any time to reply with a solution. If you find an answer before I reply back, just say so.

    Greg Collins [InfoPath MVP]
  • 08-27-2004 06:45 PM In reply to

    Re: Repeating table from XMLDataDoc

    Greg, The fix was two-fold: The row counter had to be one level higher (in this case at the group level) not at the field level where I had it. The other thing was to insert the new row to the repeating table after the first row. This works fine albeit kind of wordy. Thanks for getting me going.

    Regards,
    Frank

    ------------------------------------------

    'xnodes = XmlNodeList previously loaded

    For i = 0 To xNodes.Count - 1

    If i <> 0 Then
    'Get the xCollection name (i.e. table_2) from the advanced tab on the repeating table
    thisXDoc.View.ExecuteAction("xCollection::insert", table_2)
    End If

    With thisXDoc.DOM
    .selectSingleNode("/my:myFields/my:Group1[" & i+1 & "]/my:first").text = xNodes(i).Item("first").InnerText
    .selectSingleNode("/my:myFields/my:Group1[" & i+1 & "]/my:last").text = xNodes(i).Item("last").InnerText
    End With

    Next
  • 08-31-2004 02:55 PM In reply to

    Re: Repeating table from XMLDataDoc

    Glad you got it working!!

    Greg Collins [InfoPath MVP]
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.