Solved

Conversion of XML to CSV format in Java

Posted on 2001-06-14
8
475 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
ID: 6263048
<?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
ID: 6297292
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
ID: 6401136
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
ID: 6402812
?,...'<br>' is HTML.

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 4

Expert Comment

by:marper
ID: 6506744
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
ID: 6508857
marper,

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

0
 
LVL 4

Expert Comment

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

Expert Comment

by:Moondancer
ID: 6617567
Finalized by:
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSD Data to SQL Tables 2 25
Conditional Formatting 4 35
XML template problem 4 66
SQL XML ALL Nodes Compare in function 2 17
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

21 Experts available now in Live!

Get 1:1 Help Now