I've got a similar problem in that I've got a repeating table and whilst I can go through the while loop for each of the Rows in the table, the values don't change.
i.e. I'm trying to pull a list of activities and break them down into individual items to post to a sharepoint list for each day spent on that activity. e.g. InfoPath development is done Mon-Sunday for 2hours each day, and then SharePoint development is done Mon-Sun 4hours a day, there should be 14 items in the sharepoint list, 7 for infopah dev listing the breakdown for each day and 7 for sharepoint dev for each day. What I actually get is 14 items, but those 14 would be the infopath dev row repeated twice and no sharepoint dev at all. Here's my code
Thanks for any help I can get with this. I feel so close to getting it sorted, just stuck on this tiny bit!
First I look at the MainDataSource and then create an XPathNodeIterator which points to my repeating table
XPathNavigator domNav = MainDataSource.CreateNavigator();
XPathNodeIterator activity = domNav.Select("/my:TimesheetDetails/my:EmployeeInformation/my:TimeReporting/my:PerActivity", NamespaceManager);
My current method of collecting the node information is using this style of line
string taskActivity = activity.Current.SelectSingleNode(perActivity + "/my:TaskActivity", NamespaceManager).Value; (where perActivity = the path to my repeating table)
The problem with this method is that it only selects the first node. If I call activity.Current.Value; the value is incrementing using the while(activity.MoveNext()) command, but actually selecting the children of my repeating node doesn't work.
If I try to change the xpath in selectsinglenode to something like
string location = activity.Current.SelectSingleNode("/my:Location", NamespaceManager);
or
string location = activity.Current.SelectSingleNode("/@my:Location", NamespaceManager);
I get a "System.NullReferenceException: Object reference not set to an instance of an object." so it doesn't like that xpath.
The actual full xpath for the fields I am trying to query is "/my:TimesheetDetails/my:EmployeeInformation/my:TimeReporting/my:PerActivity/my:Location" where PerActivity is the repeating table in my form I am trying to iterate through.
I am thinking that maybe activity.Current.SelectChildren or .SelectDescendants is the correct way of what I'm trying to do but that just pulls another NodeIterator out rather than the data I need.