I have an SVG element created from a clone. What I wanted was to insert this clone into a new div. I used this code.
function clone(){
var newrect = document.getElementById('rect').cloneNode(true);
document.getElementById("svg").appendChild(newrect);
newrect.setAttribute("x", 100);
newrect.setAttribute("y", 100);
newrect.style.position = 'absolute';
var div = document.createElement('div');
document.body.appendChild(div);
div.id = 'div1';
var div1 = document.getElementById("div1");
div1.insertBefore(newrect, div1.firstChild);
}