Document 按照xml格式输出

    private void GetXMLDocument(Document doc)
    {
         OutputFormat format1 = new OutputFormat("    ", true);
         format1.setEncoding("UTF-8");
          XMLWriter out1=new XMLWriter(new PrintWriter(System.out),format1);
          try {
            out1.write(doc);
            out1.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
原文地址:https://www.cnblogs.com/dorothychai/p/3801707.html