List of usage examples for javax.xml.parsers DocumentBuilder newDocument
public abstract Document newDocument();
From source file:Main.java
/** * Factory method to create a new XML document object. * @return/*w ww . ja v a 2 s.c o m*/ */ public static final Document newXmlDocument() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder builder = dbf.newDocumentBuilder(); Document xmlDocument = builder.newDocument(); return xmlDocument; }
From source file:Main.java
public static Document makeEmptyDocument() throws Exception { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return builder.newDocument(); }
From source file:Main.java
public static Document newDocumentNS() throws Exception { DocumentBuilder parser = dbFactoryForNameSpaceBuilders.newDocumentBuilder(); return parser.newDocument(); }
From source file:Main.java
public final static Document newDocumentE() { try {//from w ww. j a v a2s. c o m DocumentBuilder bldr = getDocumentBuilder(); return bldr.newDocument(); } catch (ParserConfigurationException ex) { throw new Error(ex); } }
From source file:Main.java
public static Document createDocument() throws Exception { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); return doc;/*from w w w . j av a 2 s .com*/ }
From source file:Main.java
/** * Create a <code>Document</code> to use as a container to hold the <code>KeyInfo</code> being built. * @return Constructed but empty <code>Document<code> * @throws javax.xml.parsers.ParserConfigurationException *///from www. ja va 2s . com public static org.w3c.dom.Document buildDocument() throws ParserConfigurationException { javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder(); return db.newDocument(); }
From source file:Main.java
public static Document newDomDocument() throws IOException { try {/*ww w .j a v a 2 s . c o m*/ DocumentBuilderFactory factory = newDocumentBuilderFactory(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.newDocument(); } catch (ParserConfigurationException e) { throw new IOException("Can't create new DOM-document.", e); } }
From source file:Main.java
/** * @param .Should be followed by createRoot() * @return Creates a new Document that contains XML * @throws ParserConfigurationException/*from ww w. j ava 2 s . c om*/ * @throws SAXException * @throws IOException */ public static Document createDocument(String version, String encoding) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document parse = builder.newDocument(); parse.setXmlVersion(version); return parse; }
From source file:Main.java
/** * Create a document which is used to append XML nodes * * @return/*w ww. j a va2s . c om*/ */ public static Document getNewDocument() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); return doc; } catch (ParserConfigurationException e) { } return null; }
From source file:Main.java
/** * Create a new blank XML document./*from ww w .j a v a 2s. c om*/ * * @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; } }