a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 91|回复: 0

[基础知识] JAVA基础:jsp如何生成xml文件

[复制链接]
发表于 2012-8-4 12:37:27 | 显示全部楼层 |阅读模式
public void buildAmpieDataXML(String available, String used) throws FileNotFoundException, IOException   {
/ m7 Z& `0 H  a/ x+ S4 }  Element root = new Element(”pie”);: F, R. @8 t1 R+ u2 ^+ w
  root.addContent(new Element(”slice”).setAttribute(”title”, “可用空间”).setText(available));& R9 c% \) @2 K8 L) ?
  root.addContent(new Element(”slice”).setAttribute(”title”, “已用空间”).setText(used));# y! Y) r1 p1 K" n- O
  Document doc = new Document(root);* ~: W9 I6 p/ h0 @
  Format format = Format.getPrettyFormat();4 d5 ~0 y$ [2 Q/ q/ b
  XMLOutputter XMLOut = new XMLOutputter(format);
* n! j. t$ X% R( x0 I7 s  XMLOut.output(doc, new FileOutputStream(”/work/resin/webapps/auth-cgi/scripts/amchart/ampie/ampie_data.xml”));; E/ ~0 Y7 b/ A! H" ?/ Z* z5 R: [- D
  }
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-6 13:17 , Processed in 0.171301 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表