dom4j生成xml
生成的xml如下:
<root> <responseContent> <errCode></errCode> <responseDesc></responseDesc> </responseContent> </root>
生成xml:
private String createXml(NeopResponse neopResponse){ Document document = DocumentHelper.createDocument(); //创建文档 Element rootEle=document.addElement("root"); Element responseContentEle = rootEle.addElement("responseContent"); Element errCode=responseContentEle.addElement("errCode"); //错误编码 Element responseDesc=responseContentEle.addElement("responseDesc"); //错误描述信息 errCode.setText(neopResponse.getErrCode().toString()); responseDesc.setText(neopResponse.getResponseDesc()); String textDoc = document.asXML(); logger.info("响应的xml报文是:"+textDoc); return textDoc; }