• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XMl to flatfile conversion

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can any body give java code snippet for converting XML file to flat file.
regards
Sudhakar
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XML describes structured data. You need to decide how to convert structured data into "flat" data before anyone (and that person will be you, although we'll try to help) can write the code to do it. So: how does the XML look like, and how would it look in a non-XML text file?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And why Java? For this task I would consider using XSLT.
 
Sudhakar Rao
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The XML file looks like
<contacts>

<contact>
<name>sudhakar</name>
<email>dvvn_sudha@yahoo.com</email>
<phone>21843949</phone>
<contact>

<contact>
<name>javaking</name>
<phone>383939</phone>
</contact>

</contacts>

The converted flat file would look like this

[contacts]

[contact]
name=sudhakar email=dvvn_sudha@yahoo.com phone=21843949

name=javaking phone=383939

The requirement here is take the xml file as input and using xslt and java generate output file as flatfile.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case it's a simple XSLT and I would definitely use that.
 
Sudhakar Rao
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I have sample code for XSLT also. I want to store the flat file in unix system.
Thanks in Advance
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We don't like to give out ready-made solutions; it deprives people of the opportunity to learn. But we'll gladly try to help someone arrive at a solution; what do you have so far
 
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic