Here you can find the source of newDocument()
Parameter | Description |
---|---|
IOException | If there is an error creating the XML document. |
public static Document newDocument() throws IOException
//package com.java2s; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /**/*w ww . java 2s . com*/ * Create a new blank XML document. * * @return The new blank XML document. * * @throws IOException If there is an error creating the XML document. */ public static Document newDocument() throws IOException { try { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); return builder.newDocument(); } catch (Exception e) { IOException thrown = new IOException(e.getMessage()); throw thrown; } } }