读配置文件

 一、dom4j解析xml

      

// 获得XML文档对象
		SAXReader reader = new SAXReader();
		Document document = reader.read(new File(System.getProperty("user.dir")
				+ "conf/xxpath"));
		String name = document.getRootElement().element("name").getTextTrim();
		Element element = document.getRootElement().element("xx");
		String xx=element.elementTextTrim("xx");
		String id = element.attributeValue("id");
		//循环
		List<Element> elements = element.elements("Resource");
		for(Element e : elements){e.attributeValue("driverClassName");}

 

你可能感兴趣的:(配置文件)