Yeah, this is an age-old topic. Sorry to bore everyone. :(
But in InfoPath 2010 most of the suggestions I've read about in your forums don't seem to work. Here's a snippet of my code that I use today to populate a Repeating Table with values. It works, but if anyone can quickly spot a more efficient way of doing this by all means let me know!
DataSource sapDupes = this.DataSources["ZOLP_CHECK_DUPLICATE_ADDRESS"];
XPathNavigator sapReturn = sapDupes.CreateNavigator().SelectSingleNode("//dfs:dataFields/tns:ZOLP_CHECK_DUPLICATE_ADDRESSResponse", NamespaceManager);
if (sapReturn.SelectSingleNode("RETURN_COUNT", NamespaceManager).InnerXml != "0")
{
// Set Secondary (originating) Data Source, line item and repeating group (item)
XPathNavigator sapLineItem = sapDupes.CreateNavigator().SelectSingleNode("//dfs:dataFields/tns:ZOLP_CHECK_DUPLICATE_ADDRESSResponse/OPEN_NOTIFS_T", NamespaceManager);
XPathNodeIterator sapCodes = sapLineItem.Select("item", NamespaceManager);
// Set internal (destination) repeating group (DUPLICATE_ITEMS)
XPathNavigator onlineLineItem = MainDataSource.CreateNavigator().SelectSingleNode("//my:Duplicates", NamespaceManager);
XPathNodeIterator onlineCodes = onlineLineItem.Select("./my:Duplicate_Items", NamespaceManager);
for (int i = 1; i < sapCodes.Count; i++)
{
// blank out the first line & fields in the repeating table
onlineLineItem.AppendChildElement("my", "Duplicate_Items", onlineLineItem.LookupNamespace(onlineLineItem.Prefix), "");
XPathNavigator onlineItem = onlineLineItem.SelectSingleNode("*[last()]", NamespaceManager);
onlineItem.AppendChildElement("my", "Dupes_Date", onlineItem.LookupNamespace(onlineItem.Prefix), "");
onlineItem.AppendChildElement("my", "Dupes_Notification", onlineItem.LookupNamespace(onlineItem.Prefix), "");
onlineItem.AppendChildElement("my", "Dupes_Account", onlineItem.LookupNamespace(onlineItem.Prefix), "");
// set the position on both the originating (sap) position and the InfoPath position
XPathNavigator sapCode = sapLineItem.CreateNavigator().SelectSingleNode("item[position() = " + i + "]", NamespaceManager);
onlineItem.SelectSingleNode("my:Dupes_Date", NamespaceManager).SetValue(sapCode.SelectSingleNode("ERDAT", NamespaceManager).InnerXml);
onlineItem.SelectSingleNode("my:Dupes_Notification", NamespaceManager).SetValue(sapCode.SelectSingleNode("QMNUM", NamespaceManager).InnerXml);
onlineItem.SelectSingleNode("my:Dupes_Account", NamespaceManager).SetValue(sapCode.SelectSingleNode("NAME1", NamespaceManager).InnerXml);
}
}
Chris ... er, Arthur Fonzarelli!