@Hareesh To save comments in your XML file using the example you provided, you need to use the DOM (document object model) to read and write the XML file, not JAXB (as in the example). However, you can use the javax.xml.bind.Binder class to unmarshall your objects from a document object that you are reading from an XML file, and use the binder updateXML method to marshal your objects into a document object before writing it to an XML file.
The reason this works is because comments are supported in the document object, not in the JAXB object. You should also take a look at the updateJAXB method (if you decide to update the document object). If you post code that doesn't work, we could help better.
mario source share