Java XML Document from File getXML(File file)

Here you can find the source of getXML(File file)

Description

get XML

License

Open Source License

Declaration

public static Document getXML(File file) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.*;

public class Main {

    public static Document getXML(File file) throws Exception {
        InputStream in = new FileInputStream(file);
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
        Document xml = docBuilder.parse(in);
        in.close();//from w w w  .  ja  va  2 s.  c o  m
        return xml;
    }
}

Related

  1. getDocumentFromFile(File file)
  2. getDocumentFromFile(String absolutePath)
  3. getXML(File xmlFile)
  4. getXmlDocument(File file)
  5. getXmlDocument(File file)
  6. getXmlDocument(String fileName)