JiveJdon Community Forums
在线230人 Home | 论坛 | 培训咨询 | 精华 | 查搜 | 注册 | 登陆 |
首页 » 论坛 » 项目工程开发经验谈
???en_US.forumThreadPrev.name??? 上一主题
Go back to the topic listing   返回主题列表
???en_US.forumThreadNext.name??? 下一主题
这个主题共有 2 回复 / 1 页 [ ]  发表新帖子  回复该主题贴
xmlgoof

发表文章: 2
注册时间: 2004年10月11日 10:25
给他发消息
关于jdom的问题? 发表: 2004年10月11日 10:28 回复
在项目中,别人传给我一个对象列表 List 我这边接收并分析生成xml文件。
如下:public static String list2XML(List list)
{
root = new Element(sroot);
mydocument = new Document(root);
Element secondRoot = new Element("ceng");

Object[] o = (Object[])list.get(0);

secondRoot.addContent(o[1].toString());

root.addContent(secondRoot);
return xml2String();
}

private static String xml2String()
{
try
{
XMLOutputter outp = new XMLOutputter(" ",true,"iso8859-1");
//xmlFileName = new FileOutputStream("aa.xml");
File file = new File("d://www/aa.xml");
file.createNewFile();
outp.output(mydocument,new FileWriter(file));
//outp.output(mydocument,xmlFileName);
String string = outp.outputString(mydocument);
return string;
}
catch(Exception e)
{
e.printStackTrace();
return "error";
}
}


为什么出不来值,并且海出错误呢?
xmlgoof

发表文章: 2
注册时间: 2004年10月11日 10:25
给他发消息
Re: 关于jdom的问题? 发表: 2004年10月11日 10:30 回复
至少它应该输出一个节点的把,希望大家贯注,谢谢!
banq

发表文章: 9095
注册时间: 2002年08月03日 17:08
给他发消息
Re: 关于jdom的问题? 发表: 2004年10月11日 10:45 回复
参考JiveJdon中用法 逐步打印每行结果即可。
这个主题有 2 回复 / 1 页 [ ]
???en_US.forumThreadPrev.name??? 上一主题
Go back to the topic listing   返回主题列表    返回页首  返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Spring Struts
查询本论坛内 回复超过的热门帖子
快速发表回复
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
 

解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com

anti spam