Could someone point me to an example of creating a data connection to an XML file for a secondary data source? The data in question is being created by a different InfoPath form on the same server and in the same folder as this one, not that it should make much difference.
The example I find are all creating it via the GUI and I need to do in the code behind because my connection is dynamic (path parameter coming into the form via the URL -which I have already worked out).
Environment:
All I am trying to accomplish is to display a few fields from the other XML file in this form as read only information.
Thanks ahead of time for your time and effort!
==========UPDATE========================================
This code almost works but I run into authentication issues - and I set the form to FULL TRUST under FORM OPTIONS:
///////////////////////////////////////////////////////////////////////////
string DocTemplateURI = "https://{domain/folderpaths}/sampledata.xml?NoRedirect=true";
System.Net.
WebRequest webreq = System.Net.WebRequest.Create(DocTemplateURI);
//webreq.Credentials = new System.Net.NetworkCredential("{username}", "{pass"); //this didnt seem to help
System.Net.WebResponse webres = webreq.GetResponse();
System.IO.Stream xmlStream = webres.GetResponseStream();
XmlDocument doc = new XmlDocument();
doc.Load(xmlStream);
// Grab some data from new datasource
string title = doc.SelectSingleNode("sample/@attirbute").InnerText;
// Get reference to main datasource field I want to populate with secondary data field
XPathNavigator fieldContent = MainDataSource.CreateNavigator().SelectSingleNode("sections/section/content", NamespaceManager);
fieldContent.SetValue(title);