File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes CSV to XML coding in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "CSV to XML coding in Java" Watch "CSV to XML coding in Java" New topic

CSV to XML coding in Java

kumar m

Joined: Aug 20, 2002
Posts: 13
Hi All,
Can you give me a suggession to convert Comma Seperated Value (CSV) text file to XML file. I have to convert the CSV to XML and display the XML file in the front end using XSL.
Using java servlet and xsl.
Please help me with coding.
Thank you
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You can parse a CSV line using a java.util.StringTokenizer - use the form that returns tokens so you can count the fields.
Writing XML can be as simple as lots of println statements to a PrintWriter writing to a
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Plus, you'll fine more help in the XML forum, where this post is being moved to.
I agree. Here's the link:
subject: CSV to XML coding in Java
It's not a secret anymore!