格式化xml

来源:互联网 发布:全志a20 linux移植 编辑:程序博客网 时间:2024/05/29 19:33

 

 

 

SAXReader reader = new SAXReader();
  Document doc = reader.read(ClassLoader.getSystemResource("config/NewFile.xml"));
  OutputFormat oformat = OutputFormat.createCompactFormat();//紧凑的格式
//  OutputFormat.createPrettyPrint()//换行
  oformat.setEncoding("utf-8");
  
  StringWriter out = new StringWriter();
  XMLWriter writer = new XMLWriter(out,oformat);
  writer.write(doc);
  System.out.println(out.toString());

0 0
原创粉丝点击