Perhaps if I describe what it is I am trying to do again.
I have 61 fields (named fielda1, fielda2, etc to fielda61) that I have used to collect data in a view. I have a cloned node of 61 fields (named field1, field2 etc.. to field61) and I wish to copy the collected data into this cloned node.
So I need to copy fielda1 to field1, then increment by 1, then copy fielda2 to field2 through until fielda61 to field61 is copied.
Only once this loop until has copied all 61 fields, only then does the cloned node have all of it's information, and only then does it need to be appended to the parent.
So my first objective and question here is how to count how many fields(cells?) exist in the cloned node(row?).
The number is currently 61 but may change in the future. But for the purposes of testing the loop I have hard-coded 61. The example below still does not work:
{
// get a reference to the node to clone
var row = XDocument.DOM.selectSingleNode("//my:RoomData/my:RoomDetail") ;
row = row.cloneNode(true) ;
//start counter at 1
var i = 1;
while ( i <= 61 )
{
var fieldTitle = "my:field" + i;
var fieldaTitle = "//my:fielda" + i;
row.selectSingleNode(fieldTitle).text = XDocument.DOM.selectSingleNode(fieldaTitle).nodeTypedValue;
i++;
}
return(i);
var parent = XDocument.DOM.selectSingleNode("//my:RoomData") ;
parent.appendChild(row) ;
XDocument.View.SwitchView("Internal Works");
}
This does not work but if I replace loop with the following code it works. So my problem then relates to the loop.
var i = 1;
var test = "my:field" + i;
row.selectSingleNode(test).text = XDocument.DOM.selectSingleNode("//my:fielda1").nodeTypedValue;
Many thanks for continued help, Paul