Add node to xml variable

Hi i have 2 Xml and i want to move selected node to other xml :

function echangeNodes(xmlFrom,xmlTo,xpath,indexes) {
               
                bb.console.debug(indexes);
                firstNodeFrom = xmlFrom.firstChild;
                bb.console.debug(firstNodeFrom);
                firstNodeTo = xmlTo.childNodes[0];
                for(i=0;i<indexes.length;i++) {
                        var j = parseInt(indexes[i]) + 1;
                        var node = firstNodeFrom.selectNodes( xpath + "[" + j + "]");
                        bb.console.debug(" J : " + j);
                        bb.console.debug(node);
                        bb.console.debug(firstNodeTo);
                        bb.console.debug(firstNodeTo.parentNode);
                        firstNodeTo.appendChild(node);
                }

my xml is :

<xml>
<group id="0">
<id>0</id>
<name>Administrateurs</name>
<libelle>Groupe administrateurs</libelle>
<isactive>true</isactive>
</group>
<group id="2">
<id>2</id>
<name>Ingenierie de production</name>
<libelle>Ingenierie de production</libelle>
<isactive>true</isactive>
</group>
</xml>

But i have errors :

GENERIC: Javascript error: "Node cannot be inserted at the specified point in the hierarchy"

its for move line listgrid to other listgrid

best regard,
arnaud

problem solved

Sorry, i forget the selectNodes return an Array.
now its work