public static String prettyFormat(String input, int indent) {
try {
Source xmlInput = new StreamSource(new StringReader(input));
StringWriter stringWriter = new StringWriter();
StreamResult xmlOutput = new StreamResult(stringWriter);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", String.valueOf(indent));
transformer.transform(xmlInput, xmlOutput);
return xmlOutput.getWriter().toString();
} catch (Exception e) {
throw new RuntimeException(e); // simple exception handling, please review it
}
}
public static String prettyFormat(String input) {
return prettyFormat(input, 2);
}
分享到:
相关推荐
System.Net.Http.Formatting.xml
Excel: Formatting Microsoft Excel has many formatting options to make your spreadsheet more attractive and easier to read.
Chapter 14: XML Tools for J2EE: IBM, Apache, Sun, and Others . Chapter 15: Xerces . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 16: Xalan . . . . . . . . . . . . . . . . . . . . . . . . ...
XML FO (XSL格式化对象:XSL Formatting Objects)说明可视的文档格式化,而 Xpath 则访问XML文档的特定部分。而 XSLT(XSL Transformations)就是把某一XML文档转换为其他格式的实际语言。 XSLT 是什么类型的...
Week Two covers formatting using either CSS or the Extensible Sytlesheet Language, and working with XHTML and other tools for presenting XML data on the Web, or in multimedia applications. The final ...
window->preferences->java->Code style->Formatter中导入android-formatting.xml 使用方法: 安裝成功后使用快捷鍵:ctrl + shift + f ,Eclipse 自動按照官方要求調整code style XML格式化: ...
Week Two covers formatting using either CSS or the Extensible Sytlesheet Language, and working with XHTML and other tools for presenting XML data on the Web, or in multimedia applications. The final ...
Fix for incorrectly qualifying a column using the xml "modify" method (Forum post) Fix for syntax error being introduced when wrapping long lines containing multi-line strings 7.3.0.619 - 17th October...
While-you-type and standalone code formatters support new formatting options allowing simultaneous use of different cases for keywords and for system functions, for example uppercasing keywords and ...
Basic Visual Formatting in CSS
The Jedi Code Formatter is an open-source code formatter for the Borland Delphi Object-Pascal programming language. The formatter can standardise all aspects of Delphi Object Pascal and Delphi.NET ...
System.Net.Http.Formatting.dll
eclipse开发android,代码标准...1、Preference->Java->Code Style->Formatter->Import->添加android-formatting.xml文件 2、Preference->Java->Code Style->Organize Imports->Import->添加android.importorder文件
There is no configurability as to the formatter's algorithm for formatting. This is a deliberate design decision to unify our code formatting on a single format. The formatter can be used in software...
Intelligent code completion, formatting, code snippets bring convenience and effectiveness to your SQL code writing. Code navigation, obtaining quick object information, and syntax check are performed...
System.Net.Http.Formatting 4.0各版本,asp.net C#.net 都能用到
Serilog.Formatting.Log4Net是一个附加到格式的日志事件兼容XML格式。 您可以使用查看使用此格式化程序生成的日志文件。 入门 Serilog.Formatting.Log4Net提供了实现Serilog的接口的Log4NetTextFormatter类。 这是...
System.Net.Http.Formatting
The World Wide Web Consortium's Extensible Markup Language (XML) is quickly becoming the new standard for data formatting and Internet development. XML is expected to be as important to the future of ...
之前用Eclipse时,格式化XML代码,也会把顺序...File > Settings > Editor > Formatting > Show “Reformat Code” 选项 在XML处格式化代码(默认快捷键是CTRL+ALT+L ,Eclipse是:CTRL+ALT+F) 在弹出 的对话框中勾上Re