Java XML Document from File read(InputStream xml)

Here you can find the source of read(InputStream xml)

Description

read

License

LGPL

Declaration

protected static Node read(InputStream xml) throws Exception 

Method Source Code


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

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

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

import org.w3c.dom.Node;

public class Main {
    protected static Node read(InputStream xml) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        return builder.parse(xml).getDocumentElement();
    }//  w  w  w.java  2s  . c  o  m

    protected static Node read(File xml) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        return builder.parse(xml).getDocumentElement();
    }
}

Related

  1. loadXml(String fn)
  2. loadXMLDocument(String path)
  3. loadXmlDocumentFromFile(@Nonnull File file)
  4. loadXmlFromFile(String xmlFileName)
  5. read(InputStream input)
  6. read(java.io.File file)
  7. read(String file)
  8. read(String filename)
  9. readDocument(String fileName)