I have a Java app that uses Jackson to generate a xml, but the final xml doesn't have the <?xml version = "1.0" encoding = "UTF-8" standalone = "yes"?>
at the beginig of the document, it starts at the <source>
tag.
I need this tag to appear at the top, but I can't manage to do so.
CodePudding user response:
Assuming you are using XmlMapper you can add 'WRITE_XML_DECLARATION' configuration to add it
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);//XML declaration
See, this question - Easy way to add DOCTYPE to XML with Jackson