Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.xml.parsers.*; import java.io.File; public class Main { public static Object getBean() { try { DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dFactory.newDocumentBuilder(); Document doc = builder.parse(new File("src/config.xml")); NodeList nl = doc.getElementsByTagName("className"); Node node = nl.item(0).getFirstChild(); String cName = node.getNodeValue(); Class clazz = Class.forName(cName); Object obj = clazz.newInstance(); return obj; } catch (Exception e) { e.printStackTrace(); return null; } } }