zoukankan      html  css  js  c++  java
  • 关于对XML的处理

    目前看到的对XML的处理有2套,一套是使用jdom,另一套是使用dom4j

    jdom示例:

    SAXBuilder builder = new SAXBuilder(false);
    InputStream xmlInput = new FileInputStream("xxx.xml");
    Document doc = builder.build(xmlInput);
    Element root = doc.getRootElement();
    
    
    Element addDTSVersion = new Element("VersionA");
    addDTSVersion.setText(configDTSVersion);     
    Element addrallyVersion = new Element("VersionB");         
    addrallyVersion.setText(configRallyVersion);
    
    Element addTime = new Element("Maping");         
    addTime.addContent(addDTSVersion);         
    addTime.addContent(addrallyVersion);
    
    root.addContent(addTime);

    List<Element> Mapinglist = root.getChildren("Maping");

    XMLOutputter outputter = new XMLOutputter();
      try {
       String locaFileName = ConfigUtils.class.getResource("/"+fileName).toString();
       locaFileName = locaFileName.substring(6);
       outputter.output(doc, new FileOutputStream(locaFileName));
      } catch (FileNotFoundException e) {
       e.printStackTrace();
      } catch (IOException e) {
       e.printStackTrace();
      }
  • 相关阅读:
    OpenCV使用边缘提取、腐蚀、轮廓进行车牌定位
    How To Move Or Rebuild A Lob Partition
    Hadoop入门进阶步步高(三)-配置Hadoop
    [学习笔记]整体DP
    leetcode404
    leetcode349
    leetcode383
    leetcode453
    leetcode455
    leetcode167
  • 原文地址:https://www.cnblogs.com/glgl2424/p/2984098.html
Copyright © 2011-2022 走看看