25 lines
721 B
Java
25 lines
721 B
Java
import java.io.IOException;
|
|
import java.nio.file.Paths;
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
import org.w3c.dom.Document;
|
|
import org.xml.sax.SAXException;
|
|
|
|
public class XmlConnection {
|
|
private String filePath;
|
|
|
|
public XmlConnection(String filePath) {
|
|
this.filePath = filePath;
|
|
}
|
|
|
|
public Document getConnection() throws SAXException, IOException, ParserConfigurationException {
|
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
|
Document document = builder.parse(Paths.get(this.filePath).toFile());
|
|
return document;
|
|
}
|
|
}
|