Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.StringReader;

public class Main {
    private static final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    public static Document parseXML(String xml) throws ParserConfigurationException, IOException, SAXException {
        DocumentBuilder builder;
        synchronized (factory) {
            builder = factory.newDocumentBuilder();
        }
        return builder.parse(new InputSource(new StringReader(xml)));
    }
}