public static Document readDocument(String fileName) throws SAXException, IOException {
  DocumentBuilder docBuilder;
  Document result=null;
  DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
  docBuilderFactory.setIgnoringElementContentWhitespace(true);
  try {
    docBuilder=docBuilderFactory.newDocumentBuilder();
  }
 catch (  ParserConfigurationException e) {
    throw new Error(e);
  }
  File sourceFile=new File(fileName);
  result=docBuilder.parse(sourceFile);
  return result;
}

public static Document readDocument ( String fileName ) throws SAXException , IOException { DocumentBuilder docBuilder ; Document result = null ; DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory . newInstance ( ) ; docBuilderFactory . setIgnoringElementContentWhitespace ( true ) ; try { docBuilder = docBuilderFactory . newDocumentBuilder ( ) ; } catch ( ParserConfigurationException e ) { throw new Error ( e ) ; } File sourceFile = new File ( fileName ) ; result = docBuilder . parse ( sourceFile ) ; return result ; }
reads document from file
