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;
        }

 

posted @ 2013-01-23 10:53  合肥房屋托管  阅读(539)  评论(0编辑  收藏  举报