New javascript document

A small javascript code fragment for creating a new document containing part of an existing document
var newDoc = document.implementation.createDocument(“”, “”, null);
var sd = newDoc.importNode(content, true);
newDoc.appendChild(sd);