Matt, I was able to get your code to work but only in after I set up a rudimentry test project and I had to change the XPath in the first line to point to a repeating group instead of a field.
var oRow = XDocument.DOM.selectSingleNode("//my:employees/my:employee");
XDocument.DOM.selectSingleNode("//my:employees").appendChild( oRow.cloneNode(false) );
Unfortunately I haven't found the right XPath in my actual project to make the code work. I've looked up other examples of code that use XPaths but I haven't had any success understanding the logic well enough to apply them to my work.
If I create a new function, eg OnContextChange, InfoPath writes the XPath of the control you are creating the code for into the comment area. For the control that I need to clone the XPath is "/dfs:myFields/dfs:dataFields/d:Projects/d:PrjctTrds/d:Scores". I tried your suggestion of removing the colons which gave me the same error I've been getting. Endless trial-and-error hasn't yielded any positive results either.
Do you have any other suggestions on the correct XPath I should be using?
Thanks,
EParker @ FuzzyLogic