以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  大哥,大姐号。小弟遇到点jdom方面的问题,情指教?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=10900)


--  作者:xmlgoof
--  发布时间:10/11/2004 11:22:00 AM

--  大哥,大姐号。小弟遇到点jdom方面的问题,情指教?
在项目中,我接收别人传给我的对象列表List ,我解析成xml格式。
但是总遇到问题。代码如下:
public static String list2XML(List list)
 {
  root = new Element(sroot);
                mydocument = new Document(root);
                Element secondRoot = new Element("ceng");
                for(int i=0;i<list.size();i++)
  {
                    Object[] o;
                    try{
   o = (Object[])list.get(i);
                    }catch(Exception e)
                    {
                        System.out.print("aaaaaaaa");
                    }
                    Element node = new Element("name");
                    String a1 = o[0].toString();
                    node.addContent(a1);
                    secondRoot.addContent(node);
    
  }
                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";
  }
 }

编译都通不过,请多指教。谢谢! 再现等代


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms