去除前:
例子如下:
Document document = DocumentHelper.createDocument();
Element annotation = document.addElement("annotation");
Element folder = annotation.addElement("folder");
folder.addText(pathName);
// 将拼接成的xml转为字符串
String xml = document.asXML();
// 这里将表头直接替换掉即可
xml = xml.replaceAll("<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>", "");
去除后:
注意: 如果去除后发现第一行有空行,再使用一次replace方法替换即可