Solved

How to convert a List Object in Java to XML?

Posted on 2009-07-16
3
1,153 Views
Last Modified: 2012-08-14
I'm currently creating a web application and need to convert the Java List<Object> Type which results from a database select into an XML file. What is the most efficient way of doing this?


Thanks
0
Comment
Question by:Amos_Mike
3 Comments
 
LVL 14

Expert Comment

by:flob9
ID: 24868823
One elegant way to do this is using XML serialization, but you can also build the xml yourself using loops and string concatenation.
0
 
LVL 8

Accepted Solution

by:
ozlevanon earned 300 total points
ID: 24868954
I also recommend building the XML from actual DOM objects. This way you'll automatically ensure that everything is legal, and have a simple support for hierarchy.
You can see a sample of creating an XML structure and converting it to string here:
http://www.genedavis.com/library/xml/java_dom_xml_creation.jsp
0
 
LVL 20

Assisted Solution

by:a_b
a_b earned 200 total points
ID: 24870309
This link here has a very simple and easy to do code - http://www.roseindia.net/java/java-conversion/ObjectToXML.shtml

You need to code the xml fields though.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now