Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes Want to convert xml to csv format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Want to convert xml to csv format" Watch "Want to convert xml to csv format" New topic
Author

Want to convert xml to csv format

akshay pandit
Ranch Hand

Joined: Jun 15, 2003
Posts: 44
Hello to all !! I want to convert an xml file to csv format.Can any one help me ..
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Do you want to turn the elements of the XML into CSV in the same order or do you need to manipulate the data first?
Have you read any Java and XML tutorials? Bought a book?
Bill
Joel H. Amoussou
Greenhorn

Joined: Jun 15, 2003
Posts: 2
XSLT can be used to tramsform XML to CSV. For an example, check "XML Databases" (published by Wrox), chapter 12.
----
Joel Amoussou
IBM XML Certification Practice Test
http://www.xmlmentor.net/xmlexamsim.htm
akshay pandit
Ranch Hand

Joined: Jun 15, 2003
Posts: 44
First of all thanks for the reply...
I have read the xml file using sax parser and want to save the all the read elements/attributes & values and characters in csv format..
Suggestions will be a great help
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
If you want all the contents with various bits separated by commas, just write to an output file from every startElement and characters method. In order to get the commas in the right place you will have to pay attention to the nesting of elements.
On the other hand if you are trying to prepare data for interpretation in Excel, you need to think about what you want the resulting spreadsheet to look like.
Bill
Suresh Kanagalingam
Ranch Hand

Joined: Aug 17, 2001
Posts: 82
Check out apache web site for Xalan samples (http://xml.apache.org/xalan-j/index.html). This site has good samples showing how to convert XML into structured text format. You can change sample code to get your CSV format.
Good luck
Suresh
akshay pandit
Ranch Hand

Joined: Jun 15, 2003
Posts: 44
hi
thanks for the solution..
It really helped me a lot..
can u please let me know if we want to do a backward engineering like in our case if we want to transform csv back to xml and xls back to xml then
what can be done...?
Once again thanks for the reply...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want to convert xml to csv format
 
Similar Threads
Display euro symbol in CSV with xml + xslt
StringTokenizer to read CSV file
Java Data Converting Tool
characters in excel file
CSV to XML coding in Java