List of utility methods to do XML Document Create
Document | getDocument(String xmlDocument) get Document try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new ByteArrayInputStream(xmlDocument.getBytes("UTF-8"))); } catch (Exception e) { throw new RuntimeException("Error parsing XML document", e); |
void | getDocument(String xslName) get Document try { URL xslUri = new URL(xslName); InputStream xslIs = xslUri.openStream(); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); xsl = dBuilder.parse(xslIs); xsl.getDocumentElement().normalize(); } catch (ParserConfigurationException ex) { ... |
Document | getDocument(URL location, boolean validating, boolean namespaceAware) Create a Document representing the XML file at the specified location. return getDocument(location, validating, namespaceAware, null);
|
Document | getNewDocument() get New Document Document doc = null; try { javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory .newInstance(); javax.xml.parsers.DocumentBuilder docbuilder = factory.newDocumentBuilder(); doc = docbuilder.newDocument(); } catch (Exception e) { e.printStackTrace(); ... |
Document | getNewDocument() get New Document return getNewDocument(false);
|
Document | getNewXmlDocument() get New Xml Document try { return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (Exception e) { e.printStackTrace(); return null; |
Document | newDocument() returns a new Empty XMl Document if (docBuilder == null) { docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return docBuilder.newDocument(); |
Document | newDocument() new Document return newDocument(false);
|
Document | newDocument() new Document try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); return documentBuilderFactory.newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage(), e); |
Document | newDocument() new Document return parser.newDocument();
|