List of utility methods to do XML Document Create
Document | newXMLDocument() new XML Document Document document = getBuilder().newDocument();
return document;
|
Document | string2Document(final String xml) string Document try { final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); return documentBuilder.parse(new InputSource(new StringReader(xml))); } catch (ParserConfigurationException e) { throw new IOException(e); } catch (SAXException e) { throw new IOException(e); ... |
Document | string2Document(String xml, String encode) string Document Document document = null; DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); try { document = builder.parse(new ByteArrayInputStream(xml.getBytes(encode))); } catch (Exception e) { return document; ... |
Document | stringToDocument(final String xml) Example for retrieving the APAS institutions list return loadXMLFrom(new InputSource(new StringReader(xml))); |
Document | stringToDocument(String doc) Simple method to parse a string into a w3c Document InputStream in = new ByteArrayInputStream(doc.getBytes()); try { return getDOCUMENT_BUILDER().parse(in); } catch (IOException e) { throw new Error("Problem reading a string, should never happen", e); |
Document | stringToDocument(String string) Creates an XML Document from the given String. return streamToDocument(new ByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8))); |
Document | stringToDocument(String string) string To Document return getBuilder().parse(new ByteArrayInputStream(string.getBytes())); |
Document | stringToDocument(String string) string To Document DocumentBuilder builder = threadLocalDocumentBuilder.get(); builder.reset(); Document doc = builder.parse(new InputSource(new StringReader(string))); return doc; |
Document | stringToDocument(String xml) Converts an XML string into a DOM Document . DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); InputSource input = new InputSource(new StringReader(xml)); return factory.newDocumentBuilder().parse(input); |
Document | stringToDocument(String xmlStr, boolean isValidating) string To Document DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(isValidating); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource inputSource = new InputSource(new StringReader(xmlStr)); Document document = builder.parse(inputSource); return document; |