Solved

Conversion of XML to CSV format in Java

Posted on 2001-06-14
8
483 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:jerelw
ID: 6402812
?,...'<br>' is HTML.

0
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

623 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