Java XML Parse File parseXml(File file)

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

Description

parse Xml

License

Open Source License

Declaration

public static Document parseXml(File file) throws Exception 

Method Source Code


//package com.java2s;
// This software is released under the Apache License 2.0.

import org.w3c.dom.*;

import javax.xml.parsers.*;

import java.io.*;

public class Main {
    public static Document parseXml(File file) throws Exception {
        return newDocumentBuilder().parse(file);
    }/*from ww w  .j  av a2  s .c  om*/

    public static Document parseXml(String xml) throws Exception {
        return newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes("UTF-8")));
    }

    private static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        domFactory.setNamespaceAware(false);
        return domFactory.newDocumentBuilder();
    }
}

Related

  1. parseFile(final File aFile)
  2. parseFile(String fileName)
  3. parseFile(String fname)
  4. parsePage(String filePath)
  5. parseXml(File file)
  6. parseXml(File file)
  7. parseXML(final File file)
  8. parseXml(String fileName)
  9. parseXml(String filename, boolean validating)