Results 1 to 2 of 2
  1. #1
    SindhuP is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default 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>

  2. #2
    SindhuP is offline Member
    Join Date
    Aug 2012
    Posts
    10
    Rep Power
    0

    Default Re: Read Complex XML and write the data to a fixed field length flatfile

    Quote Originally Posted by SindhuP View Post
    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>
    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

  1. Replies: 1
    Last Post: 03-02-2012, 06:40 PM
  2. How to read and write data via Serial Port
    By Khan05 in forum New To Java
    Replies: 0
    Last Post: 07-28-2011, 10:32 PM
  3. How do I write or read data text?
    By off99555 in forum Advanced Java
    Replies: 1
    Last Post: 12-08-2010, 11:37 AM
  4. Maximum Length of A field in Lucene
    By Mayank15 in forum Lucene
    Replies: 1
    Last Post: 08-18-2010, 06:09 PM
  5. How to read a fixed number of bytes in a DataInputStream
    By Michailangelo in forum Networking
    Replies: 4
    Last Post: 06-29-2010, 03:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •