Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; public class Main { public static final Document createDocument(boolean standalone, String xmlVersion) { Document result = null; try { result = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); result.setXmlStandalone(standalone); result.setXmlVersion(xmlVersion); } catch (ParserConfigurationException e) { e.printStackTrace(); } return result; } }