zoukankan      html  css  js  c++  java
  • Jdom生成xml文件时的特殊字符问题

    import org.jdom.CDATA;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.output.Format;
    import org.jdom.output.XMLOutputter;

        

    public static String toXML(String path) throws IOException { Element root = new Element("ADI"); // 将根节点添加到文档中; Document Doc = new Document(root); CDATA text = null; // 创建节点 Element elements = new Element("Objects"); Element title = new Element("title"); title.setAttribute("Name", "title"); text = new CDATA(""); text.setText("125722130016"); title.setContent(text); object.addContent(title); Element vodfile = new Element("vodfile"); vodfile.setAttribute("Name", "vodfile"); vodfile.setText("<![CDATA[北125722130016.mp4]]>"); object.addContent(vodfile); root.addContent(elements); // 使xml文件 缩进效果 Format format = Format.getPrettyFormat(); XMLOutputter XMLOut = new XMLOutputter(format); XMLOut.output(Doc, new FileOutputStream(path)); return path; }

    compile 'org.jdom:jdom:1.1.3'

  • 相关阅读:
    基础数据类型
    python2x与python3x区别(30个)更新中。。。
    注释
    常量
    变量
    十、SpringCloud config分布式配置中心
    九、Gateway新一代网关
    八、Hystrix断路器(下)
    八、Hystrix断路器(上)
    七、OpenFeign服务接口调用
  • 原文地址:https://www.cnblogs.com/liangblog/p/12674570.html
Copyright © 2011-2022 走看看