First question is why not base the form off the database so that the main DOM is the database rather than the secondary data source?
Secondly, you can use cloneNode() and replaceChild() to do what you are asking !PROVIDED! the schemas are identical.

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Hi,
I would like to fill the DOM with an XML string received from a Web
Service, which will be identical in the structure to the Form's XML,
except the content that'll be the result of a SQL query. A sort of
auto-bind from existing data that will fill some portions of the form.
Is also possible to add controls and elements dynamically? Will they be
recognized from the XML or they need to be added one by one via code?
Thank you in advance,
Mattia
Mattia Saccotelli - 25 Nov 2004 15:03 GMT
I did the following [C# code]:
[InfoPathEventHandler(MatchPath="CTRL12_5",
EventType=InfoPathEventType.OnClick)]
public void CTRL12_5_OnClick(DocActionEvent e)
{
MSXML2.DOMDocument50Class d = new MSXML2.DOMDocument50Class();
d.async = false;
d.validateOnParse = false;
d.load(@"C:\tmp\xmlDom.xml");
d.setProperty("SelectionNamespaces",
"xmlns:xhtml='http://www.w3.org/1999/xhtml'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:po='http://schemas.microsoft.com/office/infopath/2003/sample/PurchaseOrder'
xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD'
xmlns:xd='http://schemas.microsoft.com/office/infopath/2003'");
thisXDocument.DOM.replaceChild((Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode)d.documentElement,
thisXDocument.DOM.documentElement);
}
> First question is why not base the form off the database so that the main DOM is the database rather than the secondary data source?
>
> Secondly, you can use cloneNode() and replaceChild() to do what you are asking !PROVIDED! the schemas are identical.