File xmlfile = new File(yourXMLurl);try
{
  TransformerFactory factory = TransformerFactory.newInstance();
  Source source = new DOMSource(doc);
  Result result = new StreamResult(xmlfile);
  Transformer transformer = factory.newTransformer();
  transformer.transform(source,result);
}
catch (TransformerConfigurationException e)
{}
catch (TransformerException e)
{}