I want to generate my xml file to be as below.
<CommunicationFile count="1"> <Communication><creationDate>2017-11-25</creationDate> ... </Communication> <Communication><creationDate>2017-11-25</creationDate> ... </Communication> </CommunicationFile>
I need a new line for every Communication element start.
Currently it is generating entire xml in one line. Is it possible? I am uing jackson 2.6.7 API's.
Asked
Active
Viewed 1,231 times
2

Donald Duck
- 8,409
- 22
- 75
- 99

Bhaskar
- 31
- 6
-
2Possible duplicate of https://stackoverflow.com/questions/17617370/pretty-printing-json-from-jackson-2-2s-objectmapper – Peter Dec 12 '17 at 19:58
-
I tried to use like this to format :xmlMapper.writerWithDefaultPrettyPrinter().writeValueAsString(communicationFile); But I getting error like , com.fasterxml.jackson.core.JsonGenerationException: Underlying Stax XMLStreamWriter (of type com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl$XMLStreamWriterProxy) does not implement Stax2 API natively and is missing method 'writeRaw': this breaks functionality such as indentation that relies on it. You need to upgrade to using compliant Stax implementation like Woodstox or Aalto – Bhaskar Dec 13 '17 at 14:19