/**
* Document转换为字符串
*
* @param xmlFilePath XML文件路径
* @return xmlStr 字符串
* @throws Exception
*/
public static String doc2String(Document doc) throws Exception {
Format format = Format.getPrettyFormat();
//format.setEncoding("UTF-8");// 设置xml文件的字符为UTF-8,解决中文问题
XMLOutputter xmlout = new XMLOutputter(format);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
Element rootElement = doc.getRootElement();
xmlout.output(rootElement, bo);
return bo.toString();
}