zoukankan      html  css  js  c++  java
  • java修改xml

    上几天工作需要大量的xml文档,文档的docid不能重复,所以就写了一个方法来实现,记录下来以免丢掉。

    View Code
     1 private static void ChangeId(File file,int i)throws DocumentException, IOException{
     2         UUID  uuid = UUID.randomUUID();
     3         SAXReader saxReader = new SAXReader();
     4            Document document = saxReader.read(file);
     5            List list = document.selectNodes("/document/header/docinfo/id/@value" );
     6            Iterator iter=list.iterator();
     7            while(iter.hasNext()){
     8                Attribute attribute=(Attribute)iter.next();
     9                attribute.setValue("2.16.156.12345.1.1000.204.403.167303."+i); 
    10             }
    11            File f = new File("C:/ufida/deploy/EHR_GATEWAY/EHR_GATEWAY_ADPT/XMLDATA/"+i/10000+"/");
    12            f.mkdir();
    13            OutputFormat format = OutputFormat.createPrettyPrint();
    14             format.setEncoding("utf-8");
    15         XMLWriter output = new XMLWriter(
    16                   ( new FileOutputStream("C:/ufida/deploy/EHR_GATEWAY/EHR_GATEWAY_ADPT/XMLDATA/"+i/10000+"/"+uuid.toString()+".xml") ),format);
    17                  output.write( document );
    18                  output.close();
    19 
    20     }
  • 相关阅读:
    oracle 12C linux centos7.5 安装 12C
    FizzBuzz
    批量判断能否telnet登录
    统计所有机器的挂载情况
    ffmpeg windows vs library 下载地址
    需求文档测试
    接口测试分析
    chrome网页截图
    不要为了测试写一个新系统
    C# 判断是否为数字
  • 原文地址:https://www.cnblogs.com/wangchy0927/p/2496116.html
Copyright © 2011-2022 走看看