首页 > 其他 > 详细

Jdom生成xml文件时的特殊字符问题

时间:2020-04-10 17:21:32      阅读:100      评论:0      收藏:0      [点我收藏+]

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‘

Jdom生成xml文件时的特殊字符问题

原文:https://www.cnblogs.com/liangblog/p/12674570.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!