Java XML Parse File parseFile(String fileName)

Here you can find the source of parseFile(String fileName)

Description

parse File

License

LGPL

Declaration

public static Node parseFile(String fileName) throws Exception 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.File;

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

import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class Main {
    public static Node parseFile(String fileName) throws Exception {
        File file = new File(fileName);

        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        // from AIMLProcessor.evalTemplate and AIMLProcessor.validTemplate:
        //   dbFactory.setIgnoringComments(true); // fix this
        Document doc = dBuilder.parse(file);
        doc.getDocumentElement().normalize();
        Node root = doc.getDocumentElement();
        return root;
    }/*from  www.  j a va  2s.c o m*/
}

Related

  1. parseDoc(File xmlFile)
  2. parseFile(Class context, String name)
  3. parseFile(File file)
  4. parseFile(File fn)
  5. parseFile(final File aFile)
  6. parseFile(String fname)
  7. parsePage(String filePath)
  8. parseXml(File file)
  9. parseXml(File file)