List of utility methods to do XML Document Create
Document | createNewDocument() create New Document DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.newDocument();
return document;
|
Document | createNewDocument(DocumentBuilder docBuilder) Create a new XML Document. if (docBuilder == null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(false); factory.setValidating(false); docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); return doc; ... |
Document | createNewDocument(String namespaceURI, String qualifiedName) Creates a new xml DOM Document using a DOM 3.0 DOM Implementation Document document = implementation.createDocument(namespaceURI, qualifiedName, null);
return document;
|
Document | getDocument() get Document Document document = null; DocumentBuilder db; try { db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); document = db.parse("src/exam.xml"); } catch (Exception e) { e.printStackTrace(); return document; |
Document | getDocument() Generate a document from an internal file DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); return dBuilder.parse(Thread.currentThread().getContextClassLoader() .getResourceAsStream("IntermediateXmlTest_Success2.xml")); |
Document | getDocument() get Document return documentBuilder.get().newDocument();
|
Node | getDocument(Document document) get Document return document != null ? document.getChildNodes().item(0) : null;
|
Document | getDocument(DOMSource source) Returns the Document of the given DOMSource . Node node = source.getNode(); if (node instanceof Document) { return (Document) node; } else if (node != null) { return node.getOwnerDocument(); } else { return null; |
Document | getDocument(File f) Parse a DOM Document from the given XML file. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try { DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(f); } catch (ParserConfigurationException e) { IOException ioe = new IOException(); ioe.initCause(e); ... |
Document | getDocument(File file) Parses an XML file. DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
return db.parse(file);
|