List of utility methods to do XML Parse Stream
Document | parseStream(InputStream stream, boolean validate, boolean expandEntityRefs) Parse the XML stream and return the associated W3C Document object. return parseStream(stream, validate, expandEntityRefs, false);
|
Document | parseStreamToXML(InputStream in) parse Stream To XML try {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setExpandEntityReferences(false);
builderFactory.setValidating(false);
builderFactory.setNamespaceAware(true);
builderFactory.setIgnoringComments(true);
builderFactory.setCoalescing(true);
builderFactory.setIgnoringElementContentWhitespace(true);
...
|
String | parseText(XMLStreamReader parser) parse Text for (int event = parser.next(); event != XMLStreamConstants.END_ELEMENT; event = parser.next()) { if (event == XMLStreamConstants.CHARACTERS) return parser.getText(); return null; |
String | parseValue(XMLStreamReader xmlRdr, String elementName) parse Value String val = null; while (true) { xmlRdr.next(); int event2 = xmlRdr.getEventType(); if (event2 == XMLStreamConstants.CHARACTERS) { val = xmlRdr.getText(); } else if (event2 == XMLStreamConstants.END_ELEMENT && xmlRdr.getLocalName().equals(elementName)) { return val; ... |
Document | parseXml(InputStream in) Parse an XML document. DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = domFactory.newDocumentBuilder();
return builder.parse(in);
|
Document | parseXml(InputStream in) parse Xml DocumentBuilder builder = getBuilder(); InputStream bin = new BufferedInputStream(in); Document ret = builder.parse(new InputSource(bin)); return ret; |
Document | parseXML(InputStream in) parse XML document Document document = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(in); in.close(); } catch (Exception ex) { throw new IOException(ex.getMessage()); ... |
Document | parseXml(InputStream inputStream, boolean validating) Parses an XML input stream and returns a DOM document. if (domBuilder == null) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(validating);
factory.setIgnoringComments(true);
factory.setNamespaceAware(true);
domBuilder = factory.newDocumentBuilder();
Document doc = domBuilder.parse(inputStream);
...
|
Document | parseXML(InputStream is) parse XML try { Document ret = s_dom_factory.newDocumentBuilder().parse(is); return ret; } catch (ParserConfigurationException ex) { throw new RuntimeException("Configuration Exception parsing XML: " + ex); |
Map | parseXML(InputStream is, String[] tagNames) parse XML Map<String, String> returnValues = new HashMap<String, String>(); try { DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.parse(is); Element rootElement = doc.getDocumentElement(); for (int i = 0; i < tagNames.length; i++) { NodeList targetNodes = rootElement.getElementsByTagName(tagNames[i]); if (targetNodes.getLength() <= 0) { ... |