Results 1 to 2 of 2
- 09-03-2012, 02:32 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 10
- Rep Power
- 0
Read Complex XML and write the data to a fixed field length flatfile
Hi,
I have a scenario, where I need to parse a deeply nested XML using DOM or SAX in Java. And I should write the XML data to a flat file where, each field has its own length (fixed). If any of the fields are empty, I need to write blank spaces for the length of that particular field in flat file.
So, could anyone suggest me the best approach to read and write the XML data to a flat file with fixed length.
And also there are nested childs with same name.
Thanks in Advance.
Here is the Sample XML structure I need to Parse:
Java Code:<BSN> <DTM></DTM> <HL> <TD1></TD1> <TD5></TD5> <TD3></TD3> <REF></REF> <DTM></DTM> <N1></N1> <N2></N2> <N3></N3> <N4></N4> <HL> <PRF></PRF> <REF></REF> <N1></N1> <HL> <MAN></MAN> <LIN></LIN> <SN1></SN1> <HL> </HL> </HL> </HL> </HL> <CTT></CTT> </BSN>
- 09-06-2012, 12:53 PM #2
Member
- Join Date
- Aug 2012
- Posts
- 10
- Rep Power
- 0
Re: Read Complex XML and write the data to a fixed field length flatfile
Hi All,
I am able to parse and write the XML data to fixed field length flatfile using DOM. I have written a code to check for every element in XML to add space for the particular field in flatfile basing on its fixed length. But, I got 1000 lines of code. So, I wanted to reduce that as it's not a best practice.
I request your inputs for the above scenario to suggest me the best approach I could follow.
Similar Threads
-
xsd && jaxb: how to read optional fixed attribute?
By alfonz19 in forum XMLReplies: 1Last Post: 03-02-2012, 06:40 PM -
How to read and write data via Serial Port
By Khan05 in forum New To JavaReplies: 0Last Post: 07-28-2011, 10:32 PM -
How do I write or read data text?
By off99555 in forum Advanced JavaReplies: 1Last Post: 12-08-2010, 11:37 AM -
Maximum Length of A field in Lucene
By Mayank15 in forum LuceneReplies: 1Last Post: 08-18-2010, 06:09 PM -
How to read a fixed number of bytes in a DataInputStream
By Michailangelo in forum NetworkingReplies: 4Last Post: 06-29-2010, 03:13 AM
Bookmarks