Here you can find the source of createDocument(boolean validating, boolean namespaceAware)
public static org.w3c.dom.Document createDocument(boolean validating, boolean namespaceAware) throws Exception
//package com.java2s; /*//from w w w . j av a2 s. c om * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. * This software is open source. * See the bottom of this file for the licence. */ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; public class Main { public static org.w3c.dom.Document createDocument(boolean validating, boolean namespaceAware) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(validating); factory.setNamespaceAware(namespaceAware); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.newDocument(); } }