Connect to XML via Managed Code (C#) - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Connect to XML via Managed Code (C#)

Last post 06-29-2009 11:23 AM by ccarns. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 06-29-2009 11:23 AM

    • ccarns
    • Not Ranked
    • Joined on 06-26-2009
    • Posts 9

    Connect to XML via Managed Code (C#)


     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).


    • MOSS 2007  
    • Using form services and web forms (2007)

    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!


    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();
    Stream xmlStream = webres.GetResponseStream();
    XmlDocument doc = new XmlDocument();

    // 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);

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.