Solved

Conversion of XML to CSV format in Java

Posted on 2001-06-14
8
473 Views
Last Modified: 2012-06-27
Hi,
A Java application of mine requires the exporting of data in XML format to the CSV (Excel sheet) format. I could download the code that does the reverse (CSV to XML), from the net, but could not get this. But if one of you has the java code for converting a xml string to a csv file, or if you know of a place in the net which has such an utility, please let me know.
Thanks in advance,
Regards,
KK
0
Comment
Question by:jkrishnak
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 3

Expert Comment

by:jerelw
Comment Utility
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="csv.xsl"?>
<COLLECTION>
  <BOOK>
    <TITLE>Cosmos</TITLE>
    <AUTHOR>Carl Sagan</AUTHOR>
    <PUBLISHER>Ballantine Books</PUBLISHER>
 </BOOK>
 <BOOK>
    <TITLE>Catwings</TITLE>
    <AUTHOR>Ursula K. Le Guin</AUTHOR>
    <PUBLISHER>Scholastic</PUBLISHER>
 </BOOK>
</COLLECTION>

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="/COLLECTION/BOOK">
<xsl:value-of select="TITLE"/>,<xsl:value-of select="AUTHOR"/>,<xsl:value-of select="PUBLISHER"/>&#13;&#10;
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
0
 
LVL 1

Accepted Solution

by:
vijayneema earned 100 total points
Comment Utility
you can use XSL to convert XML into text and CSV format

example

<xsl:for-each select="/LookUps/LookUp">
<xsl:value-of select="field1"/>,
<xsl:value-of select="field1"/>,
<xsl:value-of select="field1"/>
<br>
</xsl:for-each>      
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
This question was LOCKED with a PROPOSED ANSWER and awaits your decision today, no participating expert(s) has (have) been awarded for their help here.
If the Proposed Answer helped you, please accept it and award that expert.  If it did not
help you, please reject it and add comments as to status and what else is needed.

If you wish to award multiple experts, just comment here with detail.

Your response in finalizing this old question is appreciated.

Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 3

Expert Comment

by:jerelw
Comment Utility
?,...'<br>' is HTML.

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:marper
Comment Utility
vijayneema,
could you tell me please where you got that code that convert a csv file to an xml file ?
0
 
LVL 1

Expert Comment

by:vijayneema
Comment Utility
marper,

you are wrong
this code is to convert
xml to CSV string only.

0
 
LVL 4

Expert Comment

by:marper
Comment Utility
well, OK
where can I get that code ?
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Finalized by:
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
parsing xml in javascript 2 33
Merge XML files using a unique key? 8 76
xml attribute DTD attribute differences 3 58
Create XML 5 30
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 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

8 Experts available now in Live!

Get 1:1 Help Now