<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Dynamically Copying InfoPath Field Data using XML Object Model</title><link>https://www.infopathdev.com:443/forums/thread/66051.aspx</link><pubDate>Wed, 20 Apr 2011 12:13:42 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:66051</guid><dc:creator>Skarn</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/66051.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=66051</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;On repeating tables in the properties window you could use Default Values or &amp;#39;rules when user adds/inserts a row&amp;#39; and set each field to the value in your field outside the table. No code needed.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Dynamically Copying InfoPath Field Data using XML Object Model</title><link>https://www.infopathdev.com:443/forums/thread/65593.aspx</link><pubDate>Wed, 30 Mar 2011 14:40:16 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:65593</guid><dc:creator>Dan Hudnall</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/65593.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=65593</wfw:commentRss><description>&lt;p&gt;Hello All,&lt;br /&gt;I currently have a situation in which I need to dynamically populate a new row in a repeating table on an InfoPath form. I currently have three fields in a repeating table (field1, field2, field3). I also have a button that says Add Row. The code behind the button dynamically creates/appends a new field onto each previous field when the button is clicked and populates the text (Cell 1, Cell2, Cell3) respectfully. I also have a fourth text field on the form, outside of the repeating table called field4. Instead of populating standard text into fields 1,2,3, I wish to be able to copy the text/value entered in field4 into the field(s) inside the repeating table. It sounds easy but I have found it extremely difficult to understand each class and its methods for the XML object model. Could someone please take a look at the code below and perhaps show me the code to do just that. The code below is placed on the Add Row button clicked event. Any help would be wonderful. Thanks&lt;br /&gt;&lt;/p&gt;
&lt;div class="codeblock"&gt;
&lt;div class="spaced"&gt;&lt;font size="1"&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;XmlDocument&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; doc = &lt;/span&gt;&lt;span style="COLOR:#0000ff;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#0000ff;FONT-SIZE:x-small;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; &lt;/span&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;XmlDocument&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;();&lt;/font&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;"&gt;&lt;font size="1"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;/font&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;XmlNode&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; group = doc.CreateElement(&lt;/span&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;group2&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;, NamespaceManager.LookupNamespace(&lt;/span&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;my&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;));&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt; &lt;/div&gt;
&lt;div class="spaced"&gt;&lt;/font&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;XmlNode&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; field = doc.CreateElement(&lt;/span&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;field1&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;, NamespaceManager.LookupNamespace(&lt;/span&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;my&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;));&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt; &lt;/div&gt;
&lt;div class="spaced"&gt;&lt;/font&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#2b91af;FONT-SIZE:x-small;"&gt;XmlNode&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt; node = group.AppendChild(field);&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt;node.InnerText =&lt;/font&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;Cell 1&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;;&amp;nbsp; //&amp;lt;--------Instead of text here I would like the value from field4. This would require creating an instance of field4 and I am unsure of the syntax-----------&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt;field = doc.CreateElement(&lt;/font&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;field2&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;, NamespaceManager.LookupNamespace(&lt;/span&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;my&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;));&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;node = group.AppendChild(field);&lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt;node.InnerText =&lt;/font&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;Cell 2&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt;field = doc.CreateElement(&lt;/font&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;field3&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt;, NamespaceManager.LookupNamespace(&lt;/span&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;my&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;));&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;node = group.AppendChild(field);&lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;&lt;font style="FONT-SIZE:x-small;" size="2"&gt;node.InnerText =&lt;/font&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;Cell 3&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;doc.AppendChild(group);&lt;/span&gt;&lt;/div&gt;
&lt;div class="spaced"&gt;&lt;span style="FONT-SIZE:x-small;"&gt;MainDataSource.CreateNavigator().SelectSingleNode(&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&lt;span style="COLOR:#a31515;FONT-SIZE:x-small;"&gt;&amp;quot;/my:myFields/my:group1&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt;,&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE:x-small;"&gt; NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());&lt;/div&gt;
&lt;p class="spaced"&gt;&amp;nbsp;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;</description></item></channel></rss>