import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; import java.io.*; public class DbXmlParser { static String xmlfile; public DbXmlParser(String filename) { xmlfile=filename; } public static Element loadDocument() { try { //工厂 DocumentBuilderFactory dcfactory=DocumentBuilderFactory.newInstance(); //文档构造器 DocumentBuilder db=dcfactory.newDocumentBuilder(); //构造的文档 Document doc=db.parse(xmlfile); //根元素 Element root=doc.getDocumentElement(); |