Jdom

  /*读*/
  SAXBuilder builder = new SAXBuilder();
  Document doc = null;
  try {
      doc = builder.build("config.xml");
  } catch (Exception e) {
      e.printStackTrace();
      return;
  }
  //获得这个文档的根元素
  Element printer = doc.getRootElement();
  Element name = printer.getChild("name");
  this.name = name.getText();

  /*写*/
  SAXBuilder builder = new SAXBuilder();
  Document doc;
  try {
      doc = builder.build("config.xml");
  } catch (Exception e) {
        return;
  }
  Element printer = doc.getRootElement();
  Element name = printer.getChild("name");
  name.setText( PrintParameter.getInstance().getName() );
        
  XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setEncoding("utf-8"));
 try {
      outputter.output(doc, new java.io.FileOutputStream("config.xml"));
  } catch (Exception e) {
  }

posted on 2006-10-17 16:13 国强 阅读(271) 评论(0)  编辑  收藏 所属分类: java


只有注册用户登录后才能发表评论。


网站导航:
 
<2006年10月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

文章分类

文章档案

收藏夹

java

搜索

最新评论

阅读排行榜

评论排行榜