This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

please help with text formating in java

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The input file format is :
key1[0]| aaaaa |
|bbbb |
|ffff |
|ggggg |

key2[0]|ccccc |
|qqqqq |
|dddddd |

I need to read this data from text file and output should be following xml format:
<root>
<row>
<key1>aaaaa</key1>
<key2>ccccc</key2>
</row>
<row>
<key1>bbbb</key1>
<key2>qqqqq</key2>
</row>
<row>
<key1>ffff</key1>
<key2>ddddd</key2>
</row>
<row>
<key1>gggg</key1>
<key2></key2>
</row>
Please advise what will be the best way to get this output.
Thanks for all your help
smita
 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so far I have wrote this:

I would appreciate if any body can advise how to proceed next to get desired output
[ January 28, 2002: Message edited by: Cindy Glass ]
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Smita,
I would break up the reading and writing so that you have a known format when you get to the writer. Unless the input file is huge and memory is low the approach below should work.

Enjoy,
Manfred.
 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manfred,
Thanks a lot for all your help

Regards,
Smita
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!