Are you trying to convert the first xml to the second? Life would be much simpler with an XSLT transformation.
Another point is that in general the style of elements you are using is very difficult to process, you would be better off using attributes, change this:
Code:
<formData>
<CID_541_Row_503>0</CID_541_Row_503>
<CID_542_Row_503>1</CID_542_Row_503>
<CID_543_Row_503>2</CID_543_Row_503>
to something like:
Code:
<formData>
<item CID="541" Row="503">0</item>
<item CID="542" Row="503">1</item>
<item CID="543" Row="503">2</item>
I'd pick something more meaningful than item but I don't know what you are trying to represent :)
--
Joe (
Microsoft MVP - XML)