public void LeadsByCountXML() throws IOException,JDOMException{
//创建XML
// 创建根节点 list;
Element root = new Element("Request");
// 根节点添加到文档中;
Document Doc = new Document(root);
LeadsDAO dao=new LeadsDAO();
ArrayList<CountBean> list=dao.LeadsByCount();
for (CountBean cb : list) {
// 创建节点 user;
Element elements = new Element("List");
elements.addContent(new Element("Count").setText(cb.getCount()+""));
elements.addContent(new Element("CountName").setText(cb.getCountName()));
// 给父节点list添加user子节点;
root.addContent(elements);
}
XMLOutputter XMLOut = new XMLOutputter();
// 输出 user.xml 文件;
XMLOut.output(Doc, new FileOutputStream("D:/xml文件.xml"));
System.out.println(XMLOut.outputString(Doc));
}
//创建XML
// 创建根节点 list;
Element root = new Element("Request");
// 根节点添加到文档中;
Document Doc = new Document(root);
LeadsDAO dao=new LeadsDAO();
ArrayList<CountBean> list=dao.LeadsByCount();
for (CountBean cb : list) {
// 创建节点 user;
Element elements = new Element("List");
elements.addContent(new Element("Count").setText(cb.getCount()+""));
elements.addContent(new Element("CountName").setText(cb.getCountName()));
// 给父节点list添加user子节点;
root.addContent(elements);
}
XMLOutputter XMLOut = new XMLOutputter();
// 输出 user.xml 文件;
XMLOut.output(Doc, new FileOutputStream("D:/xml文件.xml"));
System.out.println(XMLOut.outputString(Doc));
}