Where there is an exported data format, there is usually a need to manually convert from the object model to the exported data format. The reason for this is that often multiple variables in the object model map to one field in the exported data format, or vice versa. eg. Street + Suburb + Postcode map to Address1.
Sometimes mapping of an object model to XML is done in third party software tools (did someone say “middleware”?) or mined directly from a database using non-portable views, however it can be more practical to use a coding language to do it, provided common elements like XML headers and tags can be created generically. This export is made easy using great little libraries such as XSTREAM where there is a 1:1 mapping between the object model and the exported data format.
But be careful – if the model object changes in structure, XSTREAM may no longer be able to read in the XML without conversion. Moreover, when a new version of the XML data structure is needed, the old mapping will have to be retained - difficult to do when mapping a java object model directly to XML.