看这里:http://blog.csdn.net/cds27/archive/2006/08/07/1031262.aspx

解决方案 »

  1.   

    同学,你没有用过大名鼎鼎的XMLOutputter?      org.jdom.Document globalDoc = (org.jdom.Document)session.getAttribute("dom");
          System.out.println("******************");
          
    org.jdom.output.Format format  =  org.jdom.output.Format.getCompactFormat();  
    format.setEncoding("gb2312");  //设置xml文件的字符为gb2312  
    format.setIndent("  ");//设置缩进
    //format.setExpandEmptyElements(true); org.jdom.output.XMLOutputter xmlOut = new org.jdom.output.XMLOutputter(format);

    //      xmlOut.setEncoding("gb2312");
    //      xmlOut.setNewlines(true);
    //      xmlOut.setIndent(2);
    //      xmlOut.setExpandEmptyElements(true);      String xml = xmlOut.outputString(globalDoc);
    //      System.out.println(xml);
      

  2.   

    http://www-128.ibm.com/developerworks/cn/java/j-jdom/