会计考友 发表于 2012-8-4 12:37:27

JAVA基础:jsp如何生成xml文件

public void buildAmpieDataXML(String available, String used) throws FileNotFoundException, IOException   {
  Element root = new Element(”pie”);
  root.addContent(new Element(”slice”).setAttribute(”title”, “可用空间”).setText(available));
  root.addContent(new Element(”slice”).setAttribute(”title”, “已用空间”).setText(used));
  Document doc = new Document(root);
  Format format = Format.getPrettyFormat();
  XMLOutputter XMLOut = new XMLOutputter(format);
  XMLOut.output(doc, new FileOutputStream(”/work/resin/webapps/auth-cgi/scripts/amchart/ampie/ampie_data.xml”));
  }
页: [1]
查看完整版本: JAVA基础:jsp如何生成xml文件