private void adminishrationToXml(Adminishration adminishration, Center center, String path){ Document document = DocumentHelper.createDocument(); //创建文档 Element employee=document.addElement("Examinatorial"); Element id= employee.addElement("ID"); //添加子节点 Element planOfTesting= employee.addElement("planOfTesting"); Element subjects= employee.addElement("subjects"); Element country= employee.addElement("country"); Element examinationRoom= employee.addElement("examinationRoom"); Element supervisor= employee.addElement("supervisor"); Element startDateTime= employee.addElement("startDateTime"); Element stopDateTime= employee.addElement("stopDateTime"); Element notice= employee.addElement("notice"); id.setText(adminishration.getIdStr()); //添加Text值 planOfTesting.setText(adminishration.getName()); subjects.setText(adminishration.getName()); country.setText(center.getOrganization().getName()); examinationRoom.setText(center.getName()); supervisor.setText(""); startDateTime.setText(adminishration.getStarttime()); stopDateTime.setText(adminishration.getStarttime()); notice.setText(""); try { Writer fileWriter=new FileWriter(path+File.separator+"Examinatorial.xml"); XMLWriter xmlWriter=new XMLWriter(fileWriter); xmlWriter.write(document); //写入文件中 xmlWriter.close(); } catch (IOException e) { System.out.println(e.getMessage()); } }