List of utility methods to do XML Parse String
Document | parseXml(Object obj) parse Xml if (domBuilderFactory == null) { domBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); DocumentBuilder parser = domBuilderFactory.newDocumentBuilder(); Document doc = null; if (obj instanceof String) { try { new URL(obj.toString()); ... |
Document | parseXML(String path) Parse XML file to Document model try { DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); dbfac.setNamespaceAware(true); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); return docBuilder.parse(new File(path)); } catch (Exception e) { e.printStackTrace(); return null; ... |
Document | parseXML(String pathToMap) Given a path to an XML instance parse it into a Document. DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setValidating(true); DocumentBuilder builder = domFactory.newDocumentBuilder(); builder.setErrorHandler(new ErrorHandler() { @Override public void error(SAXParseException exception) throws SAXException { throw exception; @Override public void fatalError(SAXParseException exception) throws SAXException { throw exception; @Override public void warning(SAXParseException exception) throws SAXException { throw exception; }); return builder.parse(pathToMap); |
String | parseXML(String resp, String name) parse XML String value = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(new StringReader(resp))); doc.getDocumentElement().normalize(); NodeList listOfProperties = doc.getElementsByTagName("ConfigCategory"); for (int i = 0; i < listOfProperties.getLength(); i++) { ... |
Node | parseXML(String text) parse XML DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = dbf.newDocumentBuilder(); InputSource source = new InputSource(new StringReader(text)); Document doc = parser.parse(source); if (doc == null) { throw new NullPointerException(); return doc.getFirstChild(); ... |
Document | parseXml(String uri) parse Xml DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(uri); } catch (Exception e) { e.printStackTrace(); return null; |
Document | parseXml(String xml) parse Xml try { DocumentBuilder dBuilder = getDocumentBuilder(); return dBuilder.parse(new ByteArrayInputStream(xml.getBytes("UTF-8"))); } catch (Exception e) { throw new RuntimeException(e); |
Document | parseXML(String xml) Parses the XML passed in as an argument and returns a Document object that represents the parsed XML DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); Document domDoc = db.parse(new ByteArrayInputStream(xml.getBytes())); domDoc.normalize(); return domDoc; } catch (ParserConfigurationException e) { e.printStackTrace(); ... |
Document | parseXML(String xml) parse XML return DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new InputSource(new StringReader(xml))); |
Document | parseXml(String xml) parse Xml try { final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); final StringReader reader = new StringReader(xml); final InputSource inputSource = new InputSource(reader); return documentBuilder.parse(inputSource); } catch (IOException ioe) { log.severe("I/O Error while parsing XML: " + ioe.getMessage()); ... |