I have tried the following with my attributes, but get an error in VS, "Error 1 The name 'XDocument' does not exist in the current context" :
The following was just written from memory and not tested. There might be some syntax errors in it, but it should give you a good idea of what needs to be done:
// Get a copy of the main DOM node.
var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:PrimaryDataSource").cloneNode(true);
// Clear the main DOM nodes.
XDocument.DOM.selectNodes("/my:myFields/my:PrimaryDataSource").removeAll();
// Copy nodes from 2DS to main DOM.
var nodes = XDocument.GetDOM("SecondaryDataSource").selectNodes("/myFields/dataFields/SecondaryDataSource"); // Note: need to supply the correct namespace per element in this XPath.
foreach(var node in nodes)
{
clone.selectSingleNode("my:Field1").text = node.selectSingleNode("Field1").text;
clone.selectSingleNode("my:Field2").text = node.selectSingleNode("Field2").text;
clone.selectSingleNode("my:Field3").text = node.selectSingleNode("Field3").text;
XDocument.DOM.selectSingleNode("my:myFields").appendChild(clone.cloneNode(true));
}