All Downloads are FREE. Search and download functionalities are using the official Maven repository.

holmos.webtest.junitextentions.parameters.xml.HolmosXMLUtils Maven / Gradle / Ivy

There is a newer version: 1.0.2u10
Show newest version
package holmos.webtest.junitextentions.parameters.xml;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

/**
 * 操作XML文件的工具类
 * 
 * @author 吴银龙([email protected])
 * */
public class HolmosXMLUtils {
	/**
	 * 从指定的绝对路径获取xml文档对象
	 * @param xmlFilePath xml文档绝对路径
	 * */
	public static Document getDocument(String xmlFilePath){
		SAXReader reader = new SAXReader();
		Document document=null;
		try {
			document=reader.read(new InputStreamReader(new FileInputStream(new File(xmlFilePath)), "GBk"));
		} catch (DocumentException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}return document;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy