Here you can find the source of createNewDocument(DocumentBuilder docBuilder)
Parameter | Description |
---|---|
docBuilder | DocumentBuilder. Setting this to null will create a new DocumentBuilder. |
public static final Document createNewDocument(DocumentBuilder docBuilder) throws ParserConfigurationException
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w .j a v a 2 s. c o m * IBM Corporation - initial API and implementation *******************************************************************************/ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; public class Main { /** * Create a new XML Document. * @param docBuilder DocumentBuilder. Setting this to null will create a new DocumentBuilder. * @return Document */ public static final Document createNewDocument(DocumentBuilder docBuilder) throws ParserConfigurationException { if (docBuilder == null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(false); factory.setValidating(false); docBuilder = factory.newDocumentBuilder(); } Document doc = docBuilder.newDocument(); return doc; } }