<?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>scripting on a repeating section</title><link>https://www.infopathdev.com:443/forums/thread/12782.aspx</link><pubDate>Tue, 21 Feb 2006 11:01:11 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12782</guid><dc:creator>Superfly1611</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12782.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12782</wfw:commentRss><description>Hello,&lt;br /&gt;&lt;br /&gt;I'm trying to write a javascript for the on_load event of my infopath form.&lt;br /&gt;The main body of my form is contained within a repeating section. Every time the user opens the infopath form I want the top node in the repeating section to be cloned and placed at the top as a kind of version control mechanism.&lt;br /&gt;&lt;br /&gt;I have tried the following code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;function XDocument::OnLoad(eventObj)&lt;br /&gt;{&lt;br /&gt;var parent = XDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:versions");&lt;br /&gt;var newChild = parent.selectSingleNode("my:version[1]").cloneNode(true);&lt;br /&gt;parent.insertBefore(newChild,parent.selectSingleNode("my:version[1]"));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The error that I am getting is that the new my:version child element is "unexpected according to content model of parent element"&lt;br /&gt;&lt;br /&gt;This makes no sense to me because the my:version element definately belongs to the my:versions parent element in the xml data structure that is produced by the infopath form.&lt;br /&gt;&lt;br /&gt;I'm pretty new to both infopath and xml scripting so any help you can offer me would be extremely helpful&lt;br /&gt;&lt;br /&gt;Many Thanks</description></item></channel></rss>