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'

  • 相关阅读:
    JS 面向对象
    inline-block元素间隙处理
    MUI
    MUI
    chrome://inspect调试html页面空白,DOM无法加载的解决方案
    MUI
    MUI
    MUI
    MUI
    MUI
  • 原文地址:https://www.cnblogs.com/liangblog/p/12674570.html
Copyright © 2011-2022 走看看