List of utility methods to do XML Parse File
Document | parse(String fileName) Parse the XML file and create Document Document document = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(new File(fileName)); return document; |
Document | parse(String xmlFile) parse DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new File(xmlFile)); |
Node | parseAIMLFile(File file) parse AIML File DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dbBuilder = dbFactory.newDocumentBuilder();
Document document = dbBuilder.parse(file);
document.getDocumentElement().normalize();
return document.getDocumentElement();
|
Document | parseData(String filename) parse Data DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); Document document = null; try { DocumentBuilder myDoc = factory.newDocumentBuilder(); File xmlFile = new File(filename); document = myDoc.parse(xmlFile); } catch (SAXException e) { e.printStackTrace(); ... |
Document | parseDoc(File xmlFile) parse Doc try (InputStream is = new FileInputStream(xmlFile)) { BufferedInputStream in = new BufferedInputStream(is); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource source = new InputSource(in); ... |
Document | parseFile(Class> context, String name) Parse an XHTML file from our CLASSPATH and return the instance. try (InputStream in = context.getResourceAsStream(name)) { if (in == null) { return null; Document doc = newBuilder().parse(in); compact(doc); return doc; } catch (SAXException | ParserConfigurationException | IOException e) { ... |
Document | parseFile(File file) parse File return newDocumentBuilder().parse(file);
|
Document | parseFile(File fn) parse File try { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(false); DocumentBuilder builder = domFactory.newDocumentBuilder(); return builder.parse(new FileInputStream(fn)); } catch (Exception e) { throw new IOException("Error parsing XML Stream", e); |
Document | parseFile(final File aFile) parse File Properties props; props = new Properties(); return parseFile(aFile, props); |
Node | parseFile(String fileName) parse File File file = new File(fileName); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(file); doc.getDocumentElement().normalize(); Node root = doc.getDocumentElement(); return root; |