List of usage examples for javax.xml.parsers DocumentBuilderFactory newInstance
public static DocumentBuilderFactory newInstance()
From source file:Main.java
public static Document createDocument() { DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; try {//from w ww. ja v a 2 s. c om docBuilder = dbfac.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } Document doc = docBuilder.newDocument(); return doc; }
From source file:Main.java
public static Document buildDocument(String fileName) throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); File file = new File(fileName); return documentBuilderFactory.newDocumentBuilder().parse(file); }
From source file:Main.java
public static Document getDocument() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(fileName); }
From source file:Main.java
public static org.w3c.dom.Document newDocument() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.newDocument(); }
From source file:Main.java
public static Document getDocFromBuffer(byte[] buf) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true);/*w ww . j a va 2s . co m*/ DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(buf)); return doc; }
From source file:Main.java
public static Document newDocument() { try {/*from w ww .j a v a 2 s .c om*/ DocumentBuilderFactory xmlFactory = DocumentBuilderFactory.newInstance(); xmlFactory.setNamespaceAware(true); DocumentBuilder builder = xmlFactory.newDocumentBuilder(); return builder.newDocument(); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static Document loadDocument(String filePath) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(filePath); return doc;/*from w w w .ja va2s. c om*/ }
From source file:Main.java
public static Document xmlToDoc(String xml) { Document doc = null;// w ww . j a v a 2 s . c om try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); doc = docBuilder.parse(xml); } catch (Exception ex) { ex.printStackTrace(); } return doc; }
From source file:Main.java
public static Document getDocument() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(filename); }
From source file:Main.java
private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringComments(true);// w w w . j a v a 2 s . c o m dbf.setCoalescing(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setValidating(false); return dbf.newDocumentBuilder(); }