Hello.
I'm using SAX to convert an XML file to a CSV file. I've got it working pretty well I think.
With the program I pass in the source xml file, and output file, the delimeter (, or :) and the number of fields.
I have a structure like such:
<Process>
<Problems>
<Problem>
<text>this is problem no 1</text>
<Sub-Problem>
<text>this is sub problem no 1</text>
<Solutions>
<Solution>
<text>this is solution 1</text>
</Solution>
<Solution>
<text>this is solution 2</text>
</Solution>
</Solutions>
</Sub_Problem>
<Sub-Problem>
<text>this is sub problem no 2</text>
<Solutions>
<Solution>
<text>this is solution 1</text>
</Solution>
<Solution>
<text>this is solution 2</text>
</Solution>
</Solutions>
</Sub_Problem>
</Problem>
</Problems>
</Process>
The concern is there are only 3 fields...Problem, SubProblem and Solution. But there can by multiple Solutions. When reading through the source how can I determine that the next element is another "solution" or a new "Problem". I would like to have a line feed after Problem, SubProblem, and all Requirements.
Right now I can output a csv file however, the output looks like:
this is problem no 1, this is subproblem 1, this is solution no1 /n
this is solution no2
instead of
this is problem no 1, this is subproblem 1, this is solution no1,this is solution no2
(all on one line)
Hope this makes sense. Any help would be appreciated.
|