This sounds like a question which might have been asked before.
But I decided not to search myself - but still try and give you an answer.
Maybe there are better methods already, or this could be one which hasn't been done.
This is a JScript method which I place behind a button.
//load the template.xml file into a new memory XML DOM
var domSample = XDocument.CreateDOM();
domSample.load("template.xml");
//collect all the nodes of the form (except root node)
var nodeChildren = XDocument.DOM.selectNodes("//my:myFields/*");
//loop through collection of nodes and remove each one
for(var i=0; i < nodeChildren.length; i++)
{
nodeChildren.item(i).parentNode.removeChild(nodeChildren.item(i));
}
//'merge' the template.xml back into the form
XDocument.ImportDOM(domSample);