Android XML Document Create getDomElement(File xmlFile)

Here you can find the source of getDomElement(File xmlFile)

Description

get Dom Element

Declaration

public static Document getDomElement(File xmlFile)
            throws ParserConfigurationException, SAXException, IOException 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class Main {
    public static Document getDomElement(File xmlFile)
            throws ParserConfigurationException, SAXException, IOException {
        Document document = null;
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
                .newInstance();//from w w w .  j a v  a2s .c  om
        DocumentBuilder documentBuilder = documentBuilderFactory
                .newDocumentBuilder();

        InputSource inputSource = new InputSource();
        inputSource.setCharacterStream(new FileReader(xmlFile));

        document = documentBuilder.parse(inputSource);

        return document;
    }
}

Related

  1. stringToDocument(String xmlString)
  2. stringToDocument(String xmlString)
  3. createDocument(final String source, boolean isNamespaceAware)
  4. createXml(Document document)
  5. getOrCreateElement(Document doc, Element manifestElement, String elementName)
  6. getDomElement(String aXml)
  7. LoadXml(String xml)