Hilary, I am having a very similar problem and hope you can help me. I am also very new to C# and XPath!!!
I am trying to copy results from a secondary datasource to a repeating table in my form. The repeating table is setup as follows
/my:myFields
/my:myFields/my:GasPrices
/my:myFields/my:GasPrices/my:GasPrice
/my:myFields/my:GasPrices/my:GasPrice/my:ItemNo
/my:myFields/my:GasPrices/my:GasPrice/my:Description
/my:myFields/my:GasPrices/my:GasPrice/my:UnitPrice
/my:myFields/my:GasPrices/my:GasPrice/my:UnitOfMeasureCode
/my:myFields/my:GasPrices/my:GasPrice/my:PriceIncludesVAT
/my:myFields/my:GasPrices/my:GasPrice/my:MonthEndDate
and my secondary datasource as follows...
/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1
/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1/ns1:Item_x0020_No_
/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1/ns1:Description
/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1/ns1:Unit_x0020_Price
/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1/ns1:Unit_x0020_of_x0020_Measure_x0020_Code
/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1/ns1:Price_x0020_Includes_x0020_VAT
/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1/ns1:Month_x0020_End_x0020_Date
Here is the code behind that I am using...
public void CTRL9_5_Clicked(object sender, ClickedEventArgs e)
{
// Access the main data source
XPathNavigator myForm = MainDataSource.CreateNavigator();
XPathNavigator myRows = myForm.SelectSingleNode("/my:myFields/my:GasPrices/my:GasPrice", NamespaceManager);
XPathNavigator parent = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:GasPrices", NamespaceManager);
//Delete the first row in the destination repeating group if it is empty
XPathNavigator myRow = myForm.SelectSingleNode("/my:myFields/my:GasPrices/my:GasPrice[1]", NamespaceManager);
if (myRow != null)
myRow.DeleteSelf();
//Select the field
XPathNavigator mySecDS = DataSources["GetGasPriceROI"].CreateNavigator();
XPathNodeIterator nodes = mySecDS.Select("/dfs:myFields/dfs:dataFields/s0:GetGasPriceROIResponse/s0:GetGasPriceROIResult/ns1:SqlRowSet1/ns1:row1", NamespaceManager);
foreach (XPathNavigator node in nodes)
{
XPathNavigator newNode = mySecDS.Clone();
newNode.SelectSingleNode("my:ItemNo", NamespaceManager).SetValue(mySecDS.SelectSingleNode("/ns1:Item_x0020_No_", NamespaceManager).Value);
newNode.SelectSingleNode("my:Description", NamespaceManager).SetValue(mySecDS.SelectSingleNode("/ns1:Description", NamespaceManager).Value);
newNode.SelectSingleNode("my:UnitPrice", NamespaceManager).SetValue(mySecDS.SelectSingleNode("/ns1:Unit_x0020_Price", NamespaceManager).Value);
newNode.SelectSingleNode("my:UnitOfMeasureCode", NamespaceManager).SetValue(mySecDS.SelectSingleNode("/ns1:Unit_x0020_Of_x0020_Measure_x0020_Code", NamespaceManager).Value);
newNode.SelectSingleNode("my:PriceIncludesVAT", NamespaceManager).SetValue(mySecDS.SelectSingleNode("/ns1:Price_x0020_Includes_x0020_VAT", NamespaceManager).Value);
newNode.SelectSingleNode("my:MonthEndDate", NamespaceManager).SetValue(mySecDS.SelectSingleNode("/ns1:Month_x0020_End_x0020_Date", NamespaceManager).Value);
parent.AppendChild(newNode);
}
}
Any help you can give me would be very much appreciated!
Thanks
Brian