Java Code Examples for org.dom4j.DocumentHelper#parseText()

The following examples show how to use org.dom4j.DocumentHelper#parseText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenwxController.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
   * 保存Ticket
   * @param xml
   */
  void processAuthorizationEvent(String xml){
  	Document doc;
try {
	doc = DocumentHelper.parseText(xml);
	Element rootElt = doc.getRootElement();
	String ticket = rootElt.elementText("ComponentVerifyTicket");
	if(oConvertUtils.isNotEmpty(ticket)){
		LogUtil.info("8、推送component_verify_ticket协议-----------ticket = "+ticket);
		WeixinOpenAccountEntity  entity = getWeixinOpenAccount(APPID);
		entity = entity==null?new WeixinOpenAccountEntity():entity;
		entity.setTicket(ticket);
		entity.setAppid(APPID);
		entity.setGetTicketTime(new Date());
		systemService.saveOrUpdate(entity);
	}
} catch (DocumentException e) {
	e.printStackTrace();
}
  }
 
Example 2
Source File: RESTUtil.java    From rest-client with Apache License 2.0 6 votes vote down vote up
/**
* 
* @Title: isXml 
* @Description: Check if it is XML string  
* @param @param xml
* @param @return 
* @return boolean
* @throws
 */
public static boolean isXml(String xml)
{
    if (StringUtils.isEmpty(xml))
    {
        return false;
    }

    try
    {
        DocumentHelper.parseText(xml);
    }
    catch(DocumentException e)
    {
        log.debug("Bad xml format: " + lines(1) + xml);
        return false;
    }

    return true;
}
 
Example 3
Source File: XmlMapper.java    From frpMgr with MIT License 6 votes vote down vote up
/**
 * xml转map 不带属性
 * @param xmlStr
 * @param needRootKey 是否需要在返回的map里加根节点键
 * @throws DocumentException
 */
@SuppressWarnings("unchecked")
public static Map<String, Object> xmlToMap(String xmlStr, boolean needRootKey) {
	try {
		Document doc = DocumentHelper.parseText(xmlStr);
		Element root = doc.getRootElement();
		Map<String, Object> map = (Map<String, Object>) xmlToMap(root);
		if (root.elements().size() == 0 && root.attributes().size() == 0) {
			return map;
		}
		if (needRootKey) {
			//在返回的map里加根节点键(如果需要)
			Map<String, Object> rootMap = new HashMap<String, Object>();
			rootMap.put(root.getName(), map);
			return rootMap;
		}
		return map;
	} catch (DocumentException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 4
Source File: WeixinInMsgParser.java    From seed with Apache License 2.0 6 votes vote down vote up
private static WeixinInMsg doParse(String xml) throws DocumentException {
    Document doc = DocumentHelper.parseText(xml);
    Element root = doc.getRootElement();
    String toUserName = root.elementText("ToUserName");
    String fromUserName = root.elementText("FromUserName");
    long createTime = Long.parseLong(root.elementText("CreateTime"));
    String msgType = root.elementText("MsgType");
    if("text".equals(msgType)){
        return parseInTextMsg(root, toUserName, fromUserName, createTime, msgType);
    }
    if("image".equals(msgType)){
        return parseInImageMsg(root, toUserName, fromUserName, createTime, msgType);
    }
    if("location".equals(msgType)){
        return parseInLocationMsg(root, toUserName, fromUserName, createTime, msgType);
    }
    if("link".equals(msgType)){
        return parseInLinkMsg(root, toUserName, fromUserName, createTime, msgType);
    }
    if("event".equals(msgType)){
        return parseInEventMsg(root, toUserName, fromUserName, createTime, msgType);
    }
    throw new RuntimeException("未知的消息类型" + msgType + ", 请查阅微信公众平台开发者文档https://mp.weixin.qq.com/wiki");
}
 
Example 5
Source File: OpenWxController.java    From jeewx-boot with Apache License 2.0 6 votes vote down vote up
public void checkWeixinAllNetworkCheck(HttpServletRequest request, HttpServletResponse response,String xml) throws DocumentException, IOException, AesException{
    String nonce = request.getParameter("nonce");
    String timestamp = request.getParameter("timestamp");
    String msgSignature = request.getParameter("msg_signature");
 
    WXBizMsgCrypt pc = new WXBizMsgCrypt(CommonWeixinProperties.COMPONENT_TOKEN, CommonWeixinProperties.COMPONENT_ENCODINGAESKEY, CommonWeixinProperties.component_appid);
    xml = pc.decryptMsg(msgSignature, timestamp, nonce, xml);
 
    Document doc = DocumentHelper.parseText(xml);
    Element rootElt = doc.getRootElement();
    String msgType = rootElt.elementText("MsgType");
    String toUserName = rootElt.elementText("ToUserName");
    String fromUserName = rootElt.elementText("FromUserName");
 
    if("event".equals(msgType)){
    	 String event = rootElt.elementText("Event");
      replyEventMessage(request,response,event,toUserName,fromUserName);
    }else if("text".equals(msgType)){
    	 String content = rootElt.elementText("Content");
      processTextMessage(request,response,content,toUserName,fromUserName);
    }
}
 
Example 6
Source File: VCardTest.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Verifies that, using a simplified template, a placeholder embedded in a element value in a template gets
 * correctly replaced.
 */
@Test
public void testReplaceEmbeddedPlaceholderVariant2() throws Exception
{
    // Setup fixture.
    final Document doc = DocumentHelper.parseText("<vcard><el>foo, {placeholder} bar</el></vcard>");
    final LdapVCardProvider.VCardTemplate template = new LdapVCardProvider.VCardTemplate(doc);
    final Map<String, String> attributes = new HashMap<>();
    attributes.put("placeholder", "value");

    // Execute system under test.
    final LdapVCardProvider.VCard vCard = new LdapVCardProvider.VCard(template);
    final Element result = vCard.getVCard(attributes);

    // Verify result.
    assertNotNull( result );
    assertEquals( "<vcard><el>foo, value bar</el></vcard>", result.asXML() );
}
 
Example 7
Source File: RuleSetReferenceUpdater.java    From urule with Apache License 2.0 5 votes vote down vote up
public boolean contain(String path, String xml) {
	try{
		Document doc=DocumentHelper.parseText(xml);
		Element element=doc.getRootElement();
		for(Object obj:element.elements()){
			if(!(obj instanceof Element)){
				continue;
			}
			Element ele=(Element)obj;
			String name=ele.getName();
			boolean match=false;
			if(name.equals("import-variable-library")){
				match=true;
			}else if(name.equals("import-constant-library")){
				match=true;
			}else if(name.equals("import-action-library")){
				match=true;
			}else if(name.equals("import-parameter-library")){
				match=true;
			}
			if(!match){
				continue;
			}
			String filePath=ele.attributeValue("path");
			if(filePath.endsWith(path)){
				return true;
			}
		}
		return false;
	}catch(Exception ex){
		throw new RuleException(ex);
	}
}
 
Example 8
Source File: RuleSetReferenceUpdater.java    From urule with Apache License 2.0 5 votes vote down vote up
public String update(String oldPath, String newPath, String xml) {
	try{
		boolean modify=false;
		Document doc=DocumentHelper.parseText(xml);
		Element element=doc.getRootElement();
		for(Object obj:element.elements()){
			if(!(obj instanceof Element)){
				continue;
			}
			Element ele=(Element)obj;
			String name=ele.getName();
			boolean match=false;
			if(name.equals("import-variable-library")){
				match=true;
			}else if(name.equals("import-constant-library")){
				match=true;
			}else if(name.equals("import-action-library")){
				match=true;
			}else if(name.equals("import-parameter-library")){
				match=true;
			}
			if(!match){
				continue;
			}
			String path=ele.attributeValue("path");
			if(path.endsWith(oldPath)){
				ele.addAttribute("path", newPath);
				modify=true;
			}
		}
		if(modify){
			return xmlToString(doc);
		}
		return null;
	}catch(Exception ex){
		throw new RuleException(ex);
	}
}
 
Example 9
Source File: StringUtil.java    From jeecg with Apache License 2.0 5 votes vote down vote up
/**
 * html 必须是格式良好的
 * @param str
 * @return
 * @throws Exception
 */
public static String formatHtml(String str) throws Exception {
	Document document = null;
	document = DocumentHelper.parseText(str);

	OutputFormat format = OutputFormat.createPrettyPrint();
	format.setEncoding("utf-8");
	StringWriter writer = new StringWriter();

	HTMLWriter htmlWriter = new HTMLWriter(writer, format);

	htmlWriter.write(document);
	htmlWriter.close();
	return writer.toString();
}
 
Example 10
Source File: Config2Object.java    From Albianj2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Object convert(@Comments("xml content") String content,
                             @Comments("xml structure with javabean class") Class<?> cls)
        throws DocumentException, IllegalAccessException, InvocationTargetException, InstantiationException {
    if (null == cls) return null;
    parseFieldsAttribute(cls);
    //将xml格式的字符串转换成Document对象
    Document doc = DocumentHelper.parseText(content);
    //获取根节点
    Element root = doc.getRootElement();
    return mergerXmlNodeAndField(root, configClasssAttr);
}
 
Example 11
Source File: HuaweiXmlParser.java    From onos with Apache License 2.0 5 votes vote down vote up
private Iterator getInterfaceIterator() {
    Document doc;
    try {
        doc = DocumentHelper.parseText(xml);
    } catch (DocumentException e) {
        throw new IllegalArgumentException(INT_PARSE_ERR);
    }
    Element root = doc.getRootElement();
    Element parent = root.element(DATA).element(IFM).element(IFS);
    return parent.elementIterator(IF);
}
 
Example 12
Source File: DecisionTableReferenceUpdater.java    From urule with Apache License 2.0 5 votes vote down vote up
public boolean contain(String path, String xml) {
	try{
		Document doc=DocumentHelper.parseText(xml);
		Element element=doc.getRootElement();
		for(Object obj:element.elements()){
			if(!(obj instanceof Element)){
				continue;
			}
			Element ele=(Element)obj;
			String name=ele.getName();
			boolean match=false;
			if(name.equals("import-variable-library")){
				match=true;
			}else if(name.equals("import-constant-library")){
				match=true;
			}else if(name.equals("import-action-library")){
				match=true;
			}else if(name.equals("import-parameter-library")){
				match=true;
			}
			if(!match){
				continue;
			}
			String filePath=ele.attributeValue("path");
			if(filePath.endsWith(path)){
				return true;
			}
		}
		return false;
	}catch(Exception ex){
		throw new RuleException(ex);
	}
}
 
Example 13
Source File: XmlMessage.java    From wechattool with MIT License 5 votes vote down vote up
public  void init(MessageDO messageDO) throws SQLException {
    xml=setTalker(messageDO.getContent());
    xml=replaceXmlSymbol(xml);
    try {
        document = DocumentHelper.parseText(xml);
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    /*
    //所有已处理的XML类型
    if(TYPE!=MSGTYPE.TYPE_BUSINESSCARD
            && TYPE!=MSGTYPE.TYPE_LINK
            &&TYPE!=MSGTYPE.TYPE_LOCATION
            && TYPE!=MSGTYPE.TYPE_SPORT
            && TYPE!= MSGTYPE.TYPE_SPOERINTERACTION
            && TYPE!=MSGTYPE.TYPE_TRANSFER
            && TYPE!=TYPE_APP_MSG
            && TYPE!= TYPE_APP_NOTION
            && TYPE!= TYPE_LOCATION_SHARING
            && TYPE!=TYPE_LOCATION_SHARING_D
            && TYPE!=TYPE_REDENVELOPE
            && TYPE!=TYPE_SHEAR
            && TYPE!=TYPE_APP
            )
        System.out.println(TYPE);*/
    if(TYPE== TYPE_LOCATION_SHARING || TYPE==TYPE_LOCATION_SHARING_D){
        title="我发起了位置共享";
    }
}
 
Example 14
Source File: XSLStringGenerationAndManipulationTests.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * The test will fail if the string generated is invalid.
 * <p>
 * This test will read three types of files and attempt to add the same to an empty string. A valid XSL file should be generated.
 *
 * @throws DocumentException
 */
@Test
public void testGenerateXSLStringFromPathWithNoText() throws DocumentException {
	boolean generatedFileValidity = false;
	final Document xslGenerated =
			DocumentHelper.parseText(XSLStringGenerationAndManipulation.generateXSLStringFromPath(this.xslFilePath.getAbsolutePath(), "", new Point(0, 0), null));
	final Document javaGenerated =
			DocumentHelper.parseText(XSLStringGenerationAndManipulation.generateXSLStringFromPath(this.javaFilePath.getAbsolutePath(), "", new Point(0, 0), null));
	final Document txtGenerated =
			DocumentHelper.parseText(XSLStringGenerationAndManipulation.generateXSLStringFromPath(this.txtFilePath.getAbsolutePath(), "", new Point(0, 0), null));
	generatedFileValidity = true;
	assertTrue(generatedFileValidity);

	final Document xslExisting = readDocFomFile(this.xslFilePath);
	assertTrue(xslGenerated.getRootElement().getName().equals(xslExisting.getRootElement().getName()));
	assertTrue(xslGenerated.getXMLEncoding().equals(xslExisting.getXMLEncoding()));
	assertTrue(xslGenerated.asXML().equals(xslExisting.asXML()));
	final Document javaExisting = readDocFomFile(this.javaXSLFilePath);
	assertTrue(javaGenerated.getRootElement().getName().equals(javaExisting.getRootElement().getName()));
	assertTrue(javaGenerated.getXMLEncoding().equals(javaExisting.getXMLEncoding()));
	assertTrue(javaGenerated.asXML().equals(javaExisting.asXML()));
	final Document txtExisting = readDocFomFile(this.txtXSLFilePath);
	assertTrue(txtGenerated.getRootElement().getName().equals(txtExisting.getRootElement().getName()));
	assertTrue(txtGenerated.getXMLEncoding().equals(txtExisting.getXMLEncoding()));
	assertTrue(txtGenerated.asXML().equals(txtExisting.asXML()));

}
 
Example 15
Source File: HuaXinSMSProvider.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
@Override
public MessageResult sendSingleMessage(String mobile, String content) throws Exception {
    org.apache.http.client.HttpClient httpclient = new SSLClient();
    HttpPost post = new HttpPost(gateway);
    post.setHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
    List<org.apache.http.NameValuePair> nvps = new ArrayList<org.apache.http.NameValuePair>();
    nvps.add(new BasicNameValuePair("action", "send"));
    nvps.add(new BasicNameValuePair("userid", ""));
    nvps.add(new BasicNameValuePair("account", username));
    nvps.add(new BasicNameValuePair("password", password));
    //多个手机号用逗号分隔
    nvps.add(new BasicNameValuePair("mobile", mobile));
    nvps.add(new BasicNameValuePair("content", content));
    nvps.add(new BasicNameValuePair("sendTime", ""));
    nvps.add(new BasicNameValuePair("extno", ""));
    post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
    HttpResponse response = httpclient.execute(post);
    System.out.println(response.getStatusLine());
    HttpEntity entity = response.getEntity();
    // 将字符转化为XML
    String returnString = EntityUtils.toString(entity, "UTF-8");
    Document doc = DocumentHelper.parseText(returnString);
    // 获取根节点
    Element rootElt = doc.getRootElement();
    // 获取根节点下的子节点的值
    String returnstatus = rootElt.elementText("returnstatus").trim();
    String message = rootElt.elementText("message").trim();
    String remainpoint = rootElt.elementText("remainpoint").trim();
    String taskID = rootElt.elementText("taskID").trim();
    String successCounts = rootElt.elementText("successCounts").trim();
    log.info(" mobile : " + mobile + "content : " + content);
    System.out.println(returnString);
    System.out.println("返回状态为:" + returnstatus);
    System.out.println("返回信息提示:" + message);
    System.out.println("返回余额:" + remainpoint);
    System.out.println("返回任务批次:" + taskID);
    System.out.println("返回成功条数:" + successCounts);
    EntityUtils.consume(entity);
    MessageResult messageResult = MessageResult.success(message);
    if (!"Success".equals(returnstatus)) {
        messageResult.setCode(500);
    }
    return messageResult;
}
 
Example 16
Source File: HuaXinSMSProvider.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
@Override
public MessageResult sendInternationalMessage(String content, String phone) throws IOException, DocumentException {
    content=String.format("[%s]Verification Code:%s.If you do not send it, please ignore this message.", sign,content);
    HttpClient client = new HttpClient();
    PostMethod method = new PostMethod(internationalGateway);
    String result = encodeHexStr(8, content);
    client.getParams().setContentCharset("UTF-8");
    method.setRequestHeader("ContentType",
            "application/x-www-form-urlencoded;charset=UTF-8");
    NameValuePair[] data = {new NameValuePair("action", "send"),
            new NameValuePair("userid", ""),
            new NameValuePair("account", internationalUsername),
            new NameValuePair("password", internationalPassword),
            new NameValuePair("mobile", phone),
            //发英文 用  0    其他中日韩 用  8
            new NameValuePair("code", "8"),
            new NameValuePair("content", result),
            new NameValuePair("sendTime", ""),
            new NameValuePair("extno", ""),};
    method.setRequestBody(data);
    client.executeMethod(method);
    String response = method.getResponseBodyAsString();
    Document doc = DocumentHelper.parseText(response);
    // 获取根节点
    Element rootElt = doc.getRootElement();
    // 获取根节点下的子节点的值
    String returnstatus = rootElt.elementText("returnstatus").trim();
    String message = rootElt.elementText("message").trim();
    String remainpoint = rootElt.elementText("balance").trim();
    String taskID = rootElt.elementText("taskID").trim();
    String successCounts = rootElt.elementText("successCounts").trim();

    System.out.println(response);
    System.out.println("返回状态为:" + returnstatus);
    System.out.println("返回信息提示:" + message);
    System.out.println("返回余额:" + remainpoint);
    System.out.println("返回任务批次:" + taskID);
    System.out.println("返回成功条数:" + successCounts);

    MessageResult messageResult = MessageResult.success();
    if (!"Success".equals(returnstatus)) {
        messageResult.setCode(500);
    }
    messageResult.setMessage(message);
    return messageResult;
}
 
Example 17
Source File: HuaXinSMSProvider.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
@Override
public MessageResult sendInternationalMessage(String content, String phone) throws IOException, DocumentException {
    content=String.format("[%s]Verification Code:%s.If you do not send it, please ignore this message.", sign,content);
    HttpClient client = new HttpClient();
    PostMethod method = new PostMethod(internationalGateway);
    String result = encodeHexStr(8, content);
    client.getParams().setContentCharset("UTF-8");
    method.setRequestHeader("ContentType",
            "application/x-www-form-urlencoded;charset=UTF-8");
    NameValuePair[] data = {new NameValuePair("action", "send"),
            new NameValuePair("userid", ""),
            new NameValuePair("account", internationalUsername),
            new NameValuePair("password", internationalPassword),
            new NameValuePair("mobile", phone),
            //发英文 用  0    其他中日韩 用  8
            new NameValuePair("code", "8"),
            new NameValuePair("content", result),
            new NameValuePair("sendTime", ""),
            new NameValuePair("extno", ""),};
    method.setRequestBody(data);
    client.executeMethod(method);
    String response = method.getResponseBodyAsString();
    Document doc = DocumentHelper.parseText(response);
    // 获取根节点
    Element rootElt = doc.getRootElement();
    // 获取根节点下的子节点的值
    String returnstatus = rootElt.elementText("returnstatus").trim();
    String message = rootElt.elementText("message").trim();
    String remainpoint = rootElt.elementText("balance").trim();
    String taskID = rootElt.elementText("taskID").trim();
    String successCounts = rootElt.elementText("successCounts").trim();

    System.out.println(response);
    System.out.println("返回状态为:" + returnstatus);
    System.out.println("返回信息提示:" + message);
    System.out.println("返回余额:" + remainpoint);
    System.out.println("返回任务批次:" + taskID);
    System.out.println("返回成功条数:" + successCounts);

    MessageResult messageResult = MessageResult.success();
    if (!"Success".equals(returnstatus)) {
        messageResult.setCode(500);
    }
    messageResult.setMessage(message);
    return messageResult;
}
 
Example 18
Source File: VariableEditorServletHandler.java    From urule with Apache License 2.0 4 votes vote down vote up
public void importXml(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	DiskFileItemFactory factory = new DiskFileItemFactory();
	ServletContext servletContext = req.getSession().getServletContext();
	File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir");
	factory.setRepository(repository);
	ServletFileUpload upload = new ServletFileUpload(factory);
	InputStream inputStream=null;
	try {
		List<FileItem> items = upload.parseRequest(req);
		if(items.size()!=1){
			throw new ServletException("Upload xml file is invalid.");
		}
		FileItem item=items.get(0);
		inputStream=item.getInputStream();
		String xmlContent=IOUtils.toString(inputStream, "utf-8");
		List<Variable> variables=new ArrayList<Variable>();
		Document doc=DocumentHelper.parseText(xmlContent);
		Element root=doc.getRootElement();
		String clazz=root.attributeValue("clazz");
		for(Object obj:root.elements()){
			if(obj==null || !(obj instanceof Element)){
				continue;
			}
			Element ele=(Element)obj;
			Variable var=new Variable();
			var.setAct(Act.InOut);
			var.setDefaultValue(ele.attributeValue("defaultValue"));
			var.setLabel(ele.attributeValue("label"));
			var.setName(ele.attributeValue("name"));
			var.setType(Datatype.valueOf(ele.attributeValue("type")));
			variables.add(var);
		}
		Map<String,Object> result=new HashMap<String,Object>();
		result.put("clazz", clazz);
		result.put("variables", variables);
		writeObjectToJson(resp, result);
	} catch (Exception e) {
		throw new ServletException(e);
	} finally {
		IOUtils.closeQuietly(inputStream);
	}
}
 
Example 19
Source File: BaseRepositoryService.java    From urule with Apache License 2.0 4 votes vote down vote up
@Override
public List<ResourcePackage> loadProjectResourcePackages(String project) throws Exception {
	Node rootNode=getRootNode();
	String filePath = processPath(project) + "/" + RES_PACKGE_FILE;
	SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	List<ResourcePackage> packages = new ArrayList<ResourcePackage>();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("res-package")) {
			continue;
		}
		ResourcePackage p = new ResourcePackage();
		String dateStr = element.attributeValue("create_date");
		if (dateStr != null) {
			p.setCreateDate(sd.parse(dateStr));
		}
		p.setId(element.attributeValue("id"));
		p.setName(element.attributeValue("name"));
		p.setProject(project);
		List<ResourceItem> items = new ArrayList<ResourceItem>();
		for (Object o : element.elements()) {
			if (!(o instanceof Element)) {
				continue;
			}
			Element ele = (Element) o;
			if (!ele.getName().equals("res-package-item")) {
				continue;
			}
			ResourceItem item = new ResourceItem();
			item.setName(ele.attributeValue("name"));
			item.setPackageId(p.getId());
			item.setPath(ele.attributeValue("path"));
			item.setVersion(ele.attributeValue("version"));
			items.add(item);
		}
		p.setResourceItems(items);
		packages.add(p);
	}
	return packages;
}
 
Example 20
Source File: XmlToJson.java    From Tpay with GNU General Public License v3.0 2 votes vote down vote up
/**
 * String 转 org.dom4j.Document
 *
 * @param xml
 * @return
 * @throws DocumentException
 */
public static Document strToDocument(String xml) throws DocumentException {
    return DocumentHelper.parseText(xml);
}