时间:2021-07-01 10:21:17 帮助过:4人阅读
把xml的encoding属性值UTF-8改为UTF8
org.xml.sax.SAXParseException: Content is not allowed in trailing section
把先要解析和字符串trim()一下即可解决问题。
解决:
1、最简单就是把改成
2、或者把xml打开另存的时候把字符集改为UTF-8后保存
或改程序
代码如下:
SAXReader reader = new SAXReader();
org.dom4j.Document document = reader.read("D:\ha.xml");
OutputFormat of = new OutputFormat();
of.setEncoding("UTF-8"); //改变编码方式
XMLWriter writer = new XMLWriter(new FileWriter "d:\dom4j.xml"), of);