List of usage examples for javax.xml.parsers DocumentBuilderFactory newInstance
public static DocumentBuilderFactory newInstance()
From source file:Main.java
public static Document getDocument(String xmlFile) { Document doc = null;/*from w w w . j a va 2 s. c o m*/ try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); doc = db.parse(new File(xmlFile)); } catch (Exception ex) { ex.printStackTrace(); } return doc; }
From source file:Main.java
public static Document getDocumentFromFile(String absolutePath) throws Exception { DocumentBuilderFactory oDocumentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder oDocumentBuilder = oDocumentBuilderFactory.newDocumentBuilder(); Document oDocument = null;/* w ww .j av a 2 s . c o m*/ oDocument = oDocumentBuilder.parse(new File(absolutePath)); return oDocument; }
From source file:Main.java
private static Document getDoc() throws ParserConfigurationException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); //root elements Document doc = docBuilder.newDocument(); return doc;/* w ww . jav a 2s . c o m*/ }
From source file:Main.java
public static Document getdoc(String uri) throws Exception { uri = uri.replace(" ", "%20"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null;//from w ww .j a va 2s . c om db = dbf.newDocumentBuilder(); Document doc = db.newDocument(); doc = db.parse(new URL(uri).openStream()); if (doc == null || doc.getTextContent() == "") { throw new Exception(); } else return doc; }
From source file:Main.java
public static Document newDocument() throws ParserConfigurationException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); return docBuilder.newDocument(); }
From source file:Main.java
public static Document createDocument() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.newDocument(); }
From source file:Main.java
public static Document fileToDOM(File file) { try {//from ww w. j a v a2 s .co m DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); return docBuilder.parse(file); } catch (Throwable t) { return null; } }
From source file:Main.java
public static Document createDoc() throws ParserConfigurationException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); return doc;/*from w ww.j av a 2 s.c o m*/ }
From source file:Main.java
public static DocumentBuilderFactory getDBF(boolean namespaceaware) { DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); fac.setValidating(false);/*from w w w .j av a 2s .c o m*/ fac.setNamespaceAware(namespaceaware); fac.setXIncludeAware(true); return fac; }
From source file:Main.java
private static Document createDocument() throws ParserConfigurationException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); return dBuilder.newDocument(); }