$("#mainDivOrSVG").find("[id]").each(function() {
$("#myAnotherDIV").append( this );
})
var svginsert = document.getElementById('svginsert');
if ($('#svginsert').length > 0) {
svginsert.removeChild
while (svginsert.firstChild) {
svginsert.removeChild(print.firstChild);
}
$('#svgwithIDs').each(function () {
svginsert.appendChild('<use xlink:href="#' + this.id + '"/>');
});
is this what you want?