File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Flat File to XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Flat File to XML" Watch "Flat File to XML" New topic

Flat File to XML

deep venu
Ranch Hand

Joined: Jun 09, 2001
Posts: 56
Could nebody suggest how would I go about converting a flat file (plain text, delimited file) into a XML Document?...
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
Its possible with java or any programming language. The structure of the xml document depends on ur system requirement.
You can aslo try to use xmlspy ,which could convert a delimted text file in to xml.
Is that what u r looking for ?

Spritle Software Blogs
deep venu
Ranch Hand

Joined: Jun 09, 2001
Posts: 56
Well, I am trying to write a custom code (in java)
to convert a delimited flat file into a XML file. I wouldn't go for a tool like XML Spy or XMl convert unless its too much of an ordeal to write custome code. If you got a sample code or something which you can share it would be gr8...
Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
Aside from just reading the flat file in and using a StringTokenizer to break up the words and manually construct the XML, you can use a custom SAX parser that reads the flat file in, applies an XSL stylesheet as the file is read in, which transforms the "events" into XML.
I haven't done this, but i've just read about it. I'm trying to remember where I read it, if you research it a little you can probably find out more about it.
I agree. Here's the link:
subject: Flat File to XML
jQuery in Action, 3rd edition