Thanks for reply.
Above solution which i posted is correct.Only i need to write xml again with some transform API.
Posting solution,if any body has the same problem.
try{
//Save the Created XML on Local Disc using Transformation APIs as Discussed
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
Source s = new DOMSource(doc);
Result res = new StreamResult( new FileOutputStream(fXmlFile));
try {
transformer.transform(s, res);
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch(TransformerConfigurationException e)
{
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}