Using JDOM to generate an XML file, what is the best way to avoid escaping characters
I tried. I can't find a way
public class JDomCreateXml {
public static void main(String[] args) throws IOException {
/**根节点*/
Element rss = new Element("rss");
rss.setAttribute("version", "2.0");
/**创建document对象*/
Document document = new Document(rss);
/**添加子节点*/
Element channel = new Element("channel");
rss.addContent(channel);
Element title = new Element("titlt");
/**设置内容*/
title.setText("<国内最新新闻>");
rss.addContent(title);
/**调节显示格式,规范格式*/
Format format = Format.getPrettyFormat();
format.setIndent("");
format.setEncoding("GBK");
/**利用xmlOutputter将document生成xml*/
XMLOutputter xmlOutputter = new XMLOutputter(format);
xmlOutputter.output(document, new FileOutputStream(new File("jdom.xml")));
}
}
I want to generate an XML file that does not need to be escaped if there are special characters