Hello All,
I am having a very urgent requirement to convert below fixed length text file into XML file. Please help me in achieveing the same.
Few points: Every line consist of 16 characters
First 3 caharacter (like D02,D03 etc will not be included in the message, coming from the sender just for reference))
Every new record will start from "H" character.
059 (occurrence 1), 040 (occurrence 1) and 084 (more than 1 occ) are the key fields to identify new segment (highlighted below)
The fields within the segments are fixed length (shown below).
Ulf Dittmer wrote:Seems relatively easy. What do have so far? Where are you stuck making progress?
Hi,
Thanks a lot for the reply!!
I am not from a java domain so not sure how i will convert this fixed file into xml as shown above.
Do you have any pointers, or if possible please share the raw peice of code i will try to manipulate it.
Thanks In Advance.
To create XML files as well as read them you should use Document Object Model. For example:
Method getNestedElement:
Above code parses this xml file:
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
1
If you haven't worked with XML in Java before, then the easiest may be to use the classes in the java.io package to read the flat file and then write out the properly formatted XML file.
Vasant Chandra
Greenhorn
Joined: Oct 06, 2012
Posts: 10
posted
0
Volodymyr Levytskyi wrote:
To create XML files as well as read them you should use Document Object Model. For example:
Hello,
Thanks for the reply!!
It looks that you are parsing/reading the XML file and converting it into text but i want just the opposite of this. I want to read the text file(shown above) and then convert it into XML format. Can you please share the code for the same.
Thanks!!
Vasant Chandra
Greenhorn
Joined: Oct 06, 2012
Posts: 10
posted
0
Hi,
Ulf Dittmer wrote:If you haven't worked with XML in Java before, then the easiest may be to use the classes in the java.io package to read the flat file and then write out the properly formatted XML file.
Do you have any sample code for the same which reads scattered fixed length data and convert into XML.
Thanks
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
No. If you haven't used java.io before, now may be a good time to learn about it. The Oracle Java Tutorial will get you started, as will any introductory book.