项目依赖:
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
生成 sitemap.xml 文件:
// xmlString 是符合 XML 格式的字符串;
// 根据 XML 字符串生成 org.dom4j.Document 对象;
Document document = DocumentHelper.parseText(xmlString);
// 指定 document 字符编码;
document.setXMLEncoding("UTF-8");
String path = "E:\\xml\\";
String fileName = "sitemap.xml";
String realPath = path + fileName;
Fi