public staticvoidDOM4Jcreate()throws Exception{
File file= new File("F:\\a.xml");
Document document= DocumentHelper.createDocument();
document.setXMLEncoding("GBK");
Element root=document.addElement("DATAS");//root.addAttribute("version", "2.0");
Element channel=root.addElement("TB_TJ_CRPTS");
Element crpt=channel.addElement("TB_TJ_CRPT");
Element rid=crpt.addElement("RID");
Element crptName=crpt.addElement("CRPT_NAME");
Element institutionCode=crpt.addElement("INSTITUTION_CODE");
rid.setText(Base64Util.encryptBASE64("12addfdg23456".getBytes()));
crptName.setText(Base64Util.encryptBASE64("伊利乳业信息集团".getBytes()));
institutionCode.setText(Base64Util.encryptBASE64("370100".getBytes()));//...
OutputFormat format =OutputFormat.createPrettyPrint();
format.setEncoding("GBK");
XMLWriter writer=new XMLWriter(new FileOutputStream(file), format);
writer.setEscapeText(false);//字符是否转义,默认true
writer.write(document);
writer.close();}