You will need to use the replaceChild() method... but there are potentially serious performance issues with doing this depending on the design of your form. The entire view will need to be redrawn, event handlers will be called, etc. You might find this to be a great hinderance.
Why are you working on a copy of the DOM instead of the DOM itself (just curious)? Have you looked into using DisableAutoUpdate and EnableAutoUpdate?

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Hello,
I would like to know how to replace the Dom xml of an InfoPath form in c#.
I have a button in my form. When it is clicked, I deserialized xml to an
object using XmlSerializer. Then I work my objects an I serialize it back to
xml. Now I want to replace the current xml of the InfoPath form, with the new
xml.
I was hoping I could use Dom.LoadXml() method, but i get the error: "This
DOM cannot be loaded twice"
Can anyone help me on this one?
Cheers,
Roeland
Roeland - 20 Jul 2005 21:46 GMT
Greg,
Thanks for you quick response!
I think it is nicer to work with objects than with xmlnodes.
From the schema that I use in InfoPath I generated object in c#.
In my InfoPath form I need to generate some repeating objects.
When I click a button in the form I go to the code(behind) from the form.
I deserialize the xml from the document and I have my objects. Once I have
them I run them through some methods with business intelligents that fill the
collection for the repeating objects.
Once I have done that I serialize those objects back to xml. And that xml
would need to replace the current xml in the dom (thisDocument.Dom.Xml)
I hope I make sense.
I’m going to have a look at “DisableAutoUpdate and EnableAutoUpdate” and
keep you up-to-date.
Thanks again for your help.
Cheers,
Roeland
> You will need to use the replaceChild() method... but there are potentially serious performance issues with doing this depending on the design of your form. The entire view will need to be redrawn, event handlers will be called, etc. You might find this to be a great hinderance.
>
[quoted text clipped - 15 lines]
> Cheers,
> Roeland