Loading a form from an XML string? - InfoPath Dev
in

InfoPath Dev

Loading a form from an XML string?

Last post 07-12-2008 05:19 AM by Hilary Stoupa. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-09-2008 01:19 PM

    • markw
    • Not Ranked
    • Joined on 07-09-2008
    • Posts 2

    Loading a form from an XML string?

    I submit my form with an XML string to a web service. I would like to load (populate) the form from the same web service, which returns the XML string. Is there an easy way to do this? If I have to do a deep copy or something, how do I start? 

  • 07-11-2008 05:55 PM In reply to

    • markw
    • Not Ranked
    • Joined on 07-09-2008
    • Posts 2

    Re: Loading a form from an XML string?

    OK, this is what I figured out:

    Given my web service data source,  the XML of the saved data I retrieved is in the node GetDataResult. I get the DOM for the GetData connection and cast is to an IXMLDOMDocument2. I use the setProperty method to setup the SelectionNamespaces so I can select the GetDataResult node. If there is no data, I don't have a previous saved version (this is how MY webservice works, yours may differ). I create a new IXMLDOMDocument and load it from the string. Now I have a source DOM I can copy from. The implementation details here are going to depend on what you want to do. In my case, I empty out a repeating list and then merge the form.

                IXMLDOMDocument2 getData = (IXMLDOMDocument2)thisXDocument.GetDOM("GetData");
                getData.setProperty("SelectionNamespaces", "xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution' xmlns:ns2='http://mywebsite.com/mynamespace'");
                IXMLDOMNode aNode = getData.selectSingleNode("/dfs:myFields/dfs:dataFields/ns2:GetDataResponse/ns2:GetDataResult");
                if (aNode.text == "") return;
                IXMLDOMDocument srcDom = thisXDocument.CreateDOM();
                srcDom.loadXML(aNode.text);
     

  • 07-12-2008 05:19 AM In reply to

    Re: Loading a form from an XML string?

    Hi, welcome, and thank you for posting your solution -- this is going to be helpful to others!

    Hilary Stoupa

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