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
Solved

Conversion of XML to CSV format in Java

Posted on 2001-06-14
8
478 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Nessus Scan 1 72
How can i generate these XML with SimpleXML() 5 77
Unable to resolve XML http request 4 99
Convert Oracle data into XML document 2 69
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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. 
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 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