Java XML Parse File parseXmlFile(String in)

Here you can find the source of parseXmlFile(String in)

Description

parse Xml File

License

Apache License

Declaration

private static Document parseXmlFile(String in) 

Method Source Code

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

import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.StringReader;

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

public class Main {
    private static Document parseXmlFile(String in) {
        try {/*  www  . j  a v  a  2  s .  c om*/
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            InputSource is = new InputSource(new StringReader(in));
            return db.parse(is);
        } catch (ParserConfigurationException | SAXException | IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. parseXMLFile(File f)
  2. parseXmlFile(File file)
  3. parseXmlFile(File file, boolean validating)
  4. parseXMLFile(final File xmlFile)
  5. parseXmlFile(String filename, boolean validating)
  6. parseXmlFile(String xml)
  7. parseXmlFile(String xmlFile)
  8. parseXmlFile(String xmlFile)