dom4j生成xml

1、XMLWriter输出domcument对象:
XMLWriter writer = null;
 try {
   // 输出到response.writer流中
    writer = new XMLWriter(response.getWriter(), format);
   // 输出到文件流中		
    writer = new XMLWriter(new FileWriter(new File("D:\\a.xml")));   
   writer.write(document);
 } catch (IOException e) {
    e.printStackTrace();
 } finally {
    if (null != writer) {
     try {
       writer.close();
     } catch (IOException e) {
       throw new A8Exception("close stream exception:" + e.getMessage());
     }
 }

你可能感兴趣的:(xml)