I have some data class that user the @XmlType annotation e I need to print in console they in XML format, how can I do this, I don't have a external ou a XML file to read, in my code I generate the XML structure.
Asked
Active
Viewed 166 times
1
-
If you use JAXB to convert an object into an XML file, this can be done easily. – hfontanez Jan 18 '22 at 15:02
-
@hfontanez any example please? – Italo Vieira Jan 18 '22 at 15:04
-
https://stackoverflow.com/questions/70744724/how-to-read-xml-file-using-java/70749964#70749964 – hfontanez Jan 18 '22 at 15:07
-
If you find JAXB to be overkill, you can do something like this https://www.journaldev.com/71/java-xml-formatter – hfontanez Jan 18 '22 at 15:08
-
@hfontanez just found it https://howtodoinjava.com/jaxb/write-object-to-xml/ and worked beautifully, thank you so much – Italo Vieira Jan 18 '22 at 15:12
-
I am a JAXB fan. Have been using it for about 16 years. LOL The post I wrote, goes in detail from getting the compiler, using XML Copy Editor to reverse engineer XML schemas and examples on reading and writing XML from/to Java objects. – hfontanez Jan 18 '22 at 15:23
-
If you need something more specific, let me know and I will post an answer to your question here. – hfontanez Jan 18 '22 at 15:26
-
1Appreciate, I never worked with SOAP and XML but I'm migrating some IBM Integration Bus that became obsolete to Java/Apache Camel and it needs to be transparent still using XML, JAXB is helping me a lot. – Italo Vieira Jan 18 '22 at 16:00