How access to a data connection in a resource file - InfoPath Dev
in

InfoPath Dev

How access to a data connection in a resource file

Last post 12-12-2006 11:21 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 12-08-2006 01:59 AM

    • Kun
    • Not Ranked
    • Joined on 11-07-2006
    • Posts 13

    How access to a data connection in a resource file

    How can I access a data connection, represented as a xml data source in a resource file in managed code?

    I use Infopath 2007 and VS 2005 and I've just found IP 2003 code:


    IXMLDOMDocument2 domSecondaryXML = (IXMLDOMDocument2)thisXDocument.CreateDOM();
    domSecondaryXML.async = false;
    domSecondaryXML.load("participantFields.xml");


    What are the equivalent IP 2007 classes?
  • 12-08-2006 09:29 AM In reply to

    Re: How access to a data connection in a resource file

    Don't load it that way.

    1. Create a data connection to the XML file (sounds like you've already done that).
    2. Use the GetDOM() method to load your XML DOM into a variable.
    3. You might need to set namespaces--if so, do that.
    4. Access your XML DOM the same as you would the main DOM from the XDocument object.
  • 12-11-2006 09:42 AM In reply to

    • Kun
    • Not Ranked
    • Joined on 11-07-2006
    • Posts 13

    Re: How access to a data connection in a resource file

    I wanted to do exactly the same as you proposed but this does not work. The bold marked line is the problem. In the debug window both InnerXml properties seem to be the same!? Why can't I set it this way?


    System.Xml.XPath.XPathNavigator fieldxpn;

    // the new values in the drop down list
    String[] newItems = { "11111", "22222222", "33333333" };

    // create a new XML document
    XmlDocument newXdoc = new XmlDocument();
    XmlElement colNames = newXdoc.CreateElement("ColumnNames");
    newXdoc.AppendChild(colNames);

    foreach (String s in newItems)
    {
    XmlElement colName = newXdoc.CreateElement("ColumnName");
    colName.InnerText = s;
    colNames.AppendChild(colName);
    }

    fieldxpn = DataSources["participantFields"].CreateNavigator();

    // ERROR: why does this not work?
    // -> "Unexpected XML declaration. The XML declaration
    // must be the first node in the document,
    // and no white space characters are allowed to appear before it.
    // Line 1, position 9."
    fieldxpn.InnerXml = newXdoc.InnerXml;
  • 12-12-2006 11:21 AM In reply to

    Re: How access to a data connection in a resource file

    Do both DOMs have the exact same namespaces? Maybe that's an issue.
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.