[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to convert a List Object in Java to XML?

Posted on 2009-07-16
3
Medium Priority
?
1,166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1200 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 800 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

650 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