167.11. 格式化的 XML marshalling (pretty-printing)
使用 prettyPrint
选项,可以在 marshalling 时输出一个良好格式化的 XML:
<dataFormats> <jacksonxml id="jack" prettyPrint="true"/> </dataFormats>
<dataFormats>
<jacksonxml id="jack" prettyPrint="true"/>
</dataFormats>
在 Java DSL 中:
from("direct:inPretty").marshal().jacksonxml(true);
from("direct:inPretty").marshal().jacksonxml(true);
请注意,有 5 个不同的过载 jacksonxml ()
DSL 方法支持 prettyPrint
选项以及 unmarshalType
、 jsonView
等其他设置。