The list of methods to do XML DOM Parse are organized into topic(s).
Document
parse_XML_String_and_create_DOM(String xmlData) Parses XML data stored in a String and generates a DOM (Document Object Model) document that contains XML data
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder DOM_document_Builder = factory.newDocumentBuilder();
return DOM_document_Builder.parse(new ByteArrayInputStream(xmlData.getBytes()));
Document
parseDom(InputStream byteArrayInputStream) parse Dom
try {
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new org.xml.sax.InputSource(byteArrayInputStream));
} catch (Exception e) {
throw new RuntimeException("Could not parse DOM for '" + byteArrayInputStream.toString() + "'!", e);
Document
parseDom(Reader reader) Creates a DOM from a file representation of an xml record
try {
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new org.xml.sax.InputSource(reader));
} catch (Exception e) {
throw new RuntimeException("Could not parse DOM for '" + reader.toString() + "'!", e);
Document
parseDOMConfigFile(String folderPath, String configFileName) parse DOM Config File
File clientConfigFile = new File(folderPath, configFileName);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(clientConfigFile);
Document
parseDomFromFile(File doc) Creates a DOM from a file representation of an xml record
FileInputStream reader;
try {
reader = new FileInputStream(doc);
} catch (FileNotFoundException e) {
throw new RuntimeException("Could not open file '" + doc.getName() + "'!", e);
return parseDom(reader);
void
parseFileToXML(Transformer transformer, DOMSource source, File file) Parse file to xml type
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
PrintWriter pw = new PrintWriter(file);
StreamResult streamResult = new StreamResult(pw);
transformer.transform(source, streamResult);
Document
parseToDom(String content) parse To Dom
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new ByteArrayInputStream(content.getBytes()));
Document
parseXMLToDOM(String xml_str) Creates a Document object from initial XML given.
Document doc = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(xml_str)));
} catch (Exception e) {
e.printStackTrace();
return doc;