格式化xml

前端之家收集整理的这篇文章主要介绍了格式化xml前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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());

猜你在找的XML相关文章