I am new to InfoPath and just need help getting the data from our Sharepoint where I can loop through the records using C# code. I have been looking at all kinds of documents and form posts, but just can't seem to get it. Can someone please help me get this data? I have tried a ton more than this code, just cant seem to get it :-(
Code I am trying (but it only returns 1 record when I know there are multiple records)
XPathNavigator domNav = this.DataSources["AuditLog"].CreateNavigator();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(domNav.NameTable);
nsmgr.AddNamespace("dfs", "http://schemas.microsoft.com/office/infopath/2003/dataFormSolution");
XPathNodeIterator xNode = domNav.Select("/dfs:myFields/dfs:dataFields", nsmgr);
// The count is only returning one record when there are multiple records
MessageBox.Show("We have " + xNode.Count.ToString() + " records");
foreach (XPathNavigator xNode2 in xNode)
{
MessageBox.Show(xNode2.InnerXml.ToString()); // This doesnt return anything
MessageBox.Show(xNode2.LocalName); // This returns "dataFields"
MessageBox.Show(xNode2.Name); // This returns "dfs:dataFields"
MessageBox.Show(xNode2.OuterXml.ToString()); // This doesnt return anything
MessageBox.Show(xNode2.NameTable.ToString()); // This returns "System.xml.NameTable"
}
XML from the Data Source
<dfs:myFields xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution">
<dfs:dataFields>
<dfs:AuditLog Title="somefile.xml" Account_Name="My Name" />
<dfs:AuditLog Title="anotherfile.xml" Account_Name="Another Name"/>
</dfs:dataFields>
</dfs:myFields>