List of utility methods to do XML InputStream Parse
Document | InputStreamToDocument(InputStream istr) Input Stream To Document DocumentBuilderFactory dFactory = DocumentBuilderFactory
.newInstance();
dFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
Document xml = dBuilder.parse(istr);
return xml;
|
Document | LoadXml(InputStream stream) Load Xml DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(stream);
return doc;
|
Document | getDocument(InputStream is) get Document DocumentBuilderFactory domfactory = DocumentBuilderFactory
.newInstance();
domfactory.setNamespaceAware(true);
DocumentBuilder builder = domfactory.newDocumentBuilder();
Document doc = builder.parse(is);
return doc;
|
XmlPullParser | getPullParser(InputStream in, String encoding) get Pull Parser XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser pullParser = null;
pullParser = factory.newPullParser();
pullParser.setInput(in, encoding);
return pullParser;
|
XmlPullParser | newPullParser(InputStream input) Create the factory if necessary and return a new pull parser. if (sFactory == null) { sFactory = XmlPullParserFactory.newInstance(); final XmlPullParser parser = sFactory.newPullParser(); parser.setInput(input, null); return parser; |
String | obtainEncodingStringFromInputStream(InputStream bis) Helper method to obtain the content encoding from an input stream. String encoding = "UTF-8"; if (!bis.markSupported()) { throw new IllegalArgumentException( "Error in the program, InputStream needs to support markSupported()"); bis.mark(ENOUGH); DataInputStream dis = new DataInputStream(bis); String line = dis.readLine(); ... |
XMLReader | parse(InputStream in, ContentHandler handler) parse XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setContentHandler(handler); reader.parse(new InputSource(in)); in.close(); return reader; |
Document | parse(InputStream is) This will parse an XML stream and create a DOM document. try { DocumentBuilderFactory builderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); return builder.parse(is); } catch (Exception e) { IOException thrown = new IOException(e.getMessage()); throw thrown; ... |
Document | parse(InputStream is) This will parse an XML stream and create a DOM document. try { DocumentBuilderFactory builderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); return builder.parse(is); } catch (FactoryConfigurationError e) { throw new IOException(e.getMessage(), e); } catch (ParserConfigurationException e) { ... |
ArrayList | parse(InputStream is, Class> cls, List parse ArrayList<Object> result = new ArrayList<Object>(); try { XmlPullParser parser = Xml.newPullParser(); parser.setInput(is, "UTF-8"); int event_type = parser.getEventType(); Object obj = null; String name = ""; while (event_type != XmlPullParser.END_DOCUMENT) { ... |