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

简介: 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'

相关文章
|
4天前
|
XML 数据格式
小米备份descript.xml文件
小米备份descript.xml文件
11 0
|
15天前
|
XML Java 数据库连接
mybatis中在xml文件中通用查询结果列如何使用
mybatis中在xml文件中通用查询结果列如何使用
20 0
|
17天前
|
XML JavaScript 前端开发
xml文件使用及解析
xml文件使用及解析
|
1月前
|
XML C# 数据格式
使用C#操作XML文件
使用C#操作XML文件
11 0
|
7天前
|
XML C# 数据格式
C# 解析XML文件
C# 解析XML文件
15 1
|
1月前
Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
15 1
|
1月前
|
XML Java 数据格式
使用java解析XML文件的步骤
使用java解析XML文件的步骤
10 0
|
1月前
|
Java
java实现遍历树形菜单方法——映射文件VoteTree.hbm.xml
java实现遍历树形菜单方法——映射文件VoteTree.hbm.xml
10 0
|
1月前
|
Kubernetes Cloud Native Java
Activiti 简介以及最新activiti依赖 pom.xml文件(使用时注意对应版本号)
Activiti 简介以及最新activiti依赖 pom.xml文件(使用时注意对应版本号)
40 2
|
1月前
|
XML Java 数据库连接
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——hibernate的config文件(hibernate.cfg.xml)
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——hibernate的config文件(hibernate.cfg.xml)
11 0