List of usage examples for javax.xml.parsers DocumentBuilderFactory newDocumentBuilder
public abstract DocumentBuilder newDocumentBuilder() throws ParserConfigurationException;
From source file:Main.java
public static Document getW3cDomDocumentFromAsset(AssetManager assetManager, String fileName) throws IOException, ParserConfigurationException, SAXException { InputStream inputStream = assetManager.open(fileName); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(inputStream); }
From source file:Main.java
public static Document parseTheXml(String thePage) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(thePage)); return db.parse(is); //build dat DOM document! }
From source file:Main.java
/** * Creates a new XML document./*from w w w .j a v a2 s .com*/ * @return the XML document */ public static Document createDocument() { try { DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); DocumentBuilder db = fact.newDocumentBuilder(); return db.newDocument(); } catch (ParserConfigurationException e) { //will probably never be thrown because we're not doing anything fancy with the configuration throw new RuntimeException(e); } }
From source file:Main.java
public static Document createDocument(String iName) throws ParserConfigurationException { DocumentBuilderFactory lFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder lBuilder = lFactory.newDocumentBuilder(); DOMImplementation lBuilderImpl = lBuilder.getDOMImplementation(); return lBuilderImpl.createDocument(null, iName, null); }
From source file:Main.java
public static Document getXMLDoc(String response) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); InputStream is = new ByteArrayInputStream(response.getBytes()); Document doc = dBuilder.parse(is); return doc;// www . j a va2 s.c o m }
From source file:Main.java
public static Document loadDoc(String filePath) throws ParserConfigurationException, SAXException, IOException { File rawXml = new File(filePath); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(rawXml); doc.getDocumentElement().normalize(); return doc;/* w w w . ja va 2 s. c o m*/ }
From source file:Main.java
static public Document parseXml(String xmlText) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(xmlText)); return db.parse(is); }
From source file:Main.java
/** * Creates a new document//from www . ja va 2s.c om * * @return the document * @throws Exception */ public static Document createDocument() throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); return builder.newDocument(); }
From source file:Main.java
public static Document InputStreamToDoc(InputStream is) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); return dBuilder.parse(is); }
From source file:Main.java
public static Document createDocument() { try {/*from w w w . ja va2s. co m*/ DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.newDocument(); return doc; } catch (Exception e) { throw new RuntimeException(e); } }