Eran Kampf
Eran Kampf
1 min read

Populating an InfoPath form with data.

In one of the prototypes I was working on I had to programmatically populate an InfoPath form with data.

After loading the required data and serializing it to the required schema I thought calling “thisXDocument.DOM.loadXML(strXmlData)” should do the job of populating the form with the data.

That call, however, triggers a “The DOM can’t be loaded twice” error.

After a quick search in the SDK help I came up with the following solution (which merges two DOMs):

  IXMLDOMDocument newDOM = thisXDocument.CreateDOM();  
  newDOM.loadXML(strXmlData);  
  thisXDocument.ImportDOM(newDOM);