Java XML Document Create newDocument()

Here you can find the source of newDocument()

Description

new Document

License

Open Source License

Declaration

public static Document newDocument() throws ParserConfigurationException 

Method Source Code


//package com.java2s;
/*//from w  ww.j  a v a  2  s. c om
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

public class Main {
    /**
     * get the XML parser factory
     */
    protected static DocumentBuilderFactory gDomFactory = null;
    /**
     * the default DOM parser
     */
    protected static DocumentBuilder gDomBuilder = null;

    public static Document newDocument() throws ParserConfigurationException {
        return getDocumentBuilder().newDocument();
    }

    public static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
        if (gDomBuilder == null) {
            gDomBuilder = getDocumentBuilderFactory().newDocumentBuilder();
        }
        return gDomBuilder;
    }

    public static DocumentBuilderFactory getDocumentBuilderFactory() {
        if (gDomFactory == null) {
            gDomFactory = DocumentBuilderFactory.newInstance();
            gDomFactory.setValidating(false);
        }
        return gDomFactory;
    }
}

Related

  1. newDocument()
  2. newDocument()
  3. newDocument()
  4. newDocument()
  5. newDocument()
  6. newDocument()
  7. newDocument()
  8. newDocument()
  9. newDocument()