List of utility methods to do XML Document from Stream
Document | loadXmlDocumentFromStream(@Nonnull InputStream in) Load the given InputStream as an XML document. Preconditions.checkNotNull(in, "Inputstream can not be null"); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); return documentBuilder.parse(in); |
Document | loadXMLFrom(final InputStream is) Loads an XML document from the input stream into a DOM Document. final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = null; builder = factory.newDocumentBuilder(); assert builder != null; final Document doc = builder.parse(is); is.close(); return doc; ... |
Document | loadXmlFromInputSource(InputSource is) load Xml From Input Source try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); return db.parse(is); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); ... |
Document | readXML(InputStream input) Parses the given input stream and returns the corresponding desirialized XML document. return readXML(new InputStreamReader(input, "UTF-8")); |
Document | readXml(InputStream inputStream) read Xml try { Document document = newDocumentBuilder().parse(inputStream); document.setXmlStandalone(true); return document; } catch (IOException e) { throw new IllegalArgumentException(e); } catch (SAXException e) { throw new IllegalArgumentException(e); ... |
Document | readXML(InputStream inputStream, EntityResolver resolver, ErrorHandler error) read XML DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); if (resolver != null) { db.setEntityResolver(resolver); if (error != null) { ... |
Node | readXML(InputStream inStream) Reads the argument XML input stream. try { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document doc = builder.parse(inStream); inStream.close(); return doc.getDocumentElement(); } catch (SAXException saxEx) { throw new IllegalArgumentException(null, saxEx); ... |
Document | readXML(InputStream is) Read input stream into XML Document element javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
org.w3c.dom.Document doc = db.parse(is);
return doc;
|