Read Complex XML and write the data to a fixed field length flatfile
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:
Re: Read Complex XML and write the data to a fixed field length flatfile
Originally Posted by SindhuP
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.