public static Document newXMLDocument(){
  DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
  try {
    DocumentBuilder builder=factory.newDocumentBuilder();
    builder.setErrorHandler(new XMLErrorHandler());
    Document doc=builder.newDocument();
    return doc;
  }
 catch (  ParserConfigurationException e) {
    log.warning(e.getMessage());
    throw new RuntimeException("cannot create XML file");
  }
}

public static Document newXMLDocument ( ) { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; try { DocumentBuilder builder = factory . newDocumentBuilder ( ) ; builder . setErrorHandler ( new XMLErrorHandler ( ) ) ; Document doc = builder . newDocument ( ) ; return doc ; } catch ( ParserConfigurationException e ) { log . warning ( e . getMessage ( ) ) ; throw new RuntimeException ( "cannot create XML file" ) ; } }
creates a new xml , empty document
