OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("GBK"); XMLWriter output = new XMLWriter(new FileWriter(new File("c:/catalog.xml")),format); output.write(document);