??????xmlд??????????
public class WriteToXml {
static List<Dep> listdep=new Dep("0000"); //0000??????
Element  root=DocumentHelper.createElement("Dep");
Document doc=DocumentHelper.createDocument();
public  void Write(List<Dep> listdep??Element element){
for(Dep dep:listdep){
//??????????????????
Element menuElement = element.addElement(dep.getDeptname());
//???????????deptcode??value?????id
Attribute att=DocumentHelper.createAttribute(menuElement?? "deptcode"??dep.getDeptcode());
menuElement.add(att);
if(dep.getChildren()!=null&&dep.getChildren().size()>0){
Write(dep.getChildren()??menuElement);
}
}
}
public void WriteAll(String path){
//??????д??root???
Write(listdep??root);
try{
XMLWriter xmlwriter=new XMLWriter(new FileWriter(new File(path)));
doc.add(root);
xmlwriter.write(doc);
xmlwriter.close();
}catch(IOException e){
e.printStackTrace();
}
}
public static void main(String[] args) {
WriteToXml t=new WriteToXml();
t.WriteAll("E://test.xml");
}
}
?????ò??????????????xml?????д????...????????xml?γ?html??????????