Does anyone know good XML library for Java which I can use to write data extracted from database into XML format?
Asked
Active
Viewed 435 times
1
-
1You might want take a look at http://stackoverflow.com/questions/831865/what-java-xml-library-do-you-recommend-to-replace-dom4j or some of the several other "Java XML library" questions: http://stackoverflow.com/questions/tagged/java+xml+library – Jonik May 03 '10 at 14:18
3 Answers
3
Usually, those tools are already provided by the database itself. Check the "Export" section somewhere in their documentation. A more detailed answer can't be given since the DB vendor is unmentioned.
Regardless, if you insist in using Java for this (which may however be performance/memory hogging with large data), then you may find a Javabean-to-XML serializer useful, for example JAXB, XStream or XMLBeans.

BalusC
- 1,082,665
- 372
- 3,610
- 3,555
-
+1; the OP would be well-served to not reinvent this particular wheel. :-) – BlairHippo May 03 '10 at 14:20
-
Thanks , but the data I need to extract from database is not from a single table , but multiple and with custom formatting. – yogsma May 03 '10 at 14:30
-
1
-
@BalusC - I understand. There is much more to this ..harmonization of data won't happen in SQL , I need to do that in my code before transforming into XML. – yogsma May 03 '10 at 14:48
-
3@yogsma: aren't you undervaluing SQL? Joins? Functions? Procedures? The average DB is undoubtely much more efficient in this job. In Java you would need to get hold of all the data in memory and then preferably need 2~5 times more free space in the memory than the data actually large is, else you will face constantly `OutOfMemoryErrors`. I would still consult some SQL Ninja (or ask here) if it is really, *really* not possible in pure SQL. Just to be sure. – BalusC May 03 '10 at 14:54
-
@BalusC - Thanks, let me figure this out little bit , else I will ask the question for sure. – yogsma May 03 '10 at 14:57
2
JAXB all you need to do is annotate a class and you can marshal it to XML. Works well with JPA entities / other ORMs as well.

Justin
- 4,097
- 1
- 22
- 31
-
+1, also the MOXy implmentation of JAXB has a number of extensions for dealing with JPA entities http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA – bdoughan Aug 12 '10 at 16:01