BeanIO - parse complex xml to flat file

349 views
Skip to first unread message

Ronen Malka

unread,
May 19, 2014, 1:35:50 PM5/19/14
to bea...@googlegroups.com
Hi,
I am trying to convert xml file to flat file using BeanIO.
My XML contains many types of records:

    <complex_xml>
        <xml_header_info>
            <report_date>10-10-2011</report_date>
            <some_global_info>some info</some_global_info>
        </xml_header_info>
        <employees>
            <employee>
                <emp_id>1</emp_id>
                <emp_name>abc</emp_name>
            </employee>
            <employee>
                <emp_id>2</emp_id>
                <emp_name>def</emp_name>
            </employee>
            <employee>
                <emp_id>3</emp_id>
                <emp_name>xyz</emp_name>
            </employee>
            <!-- more employees -->
        </employees>
        <contacts>
            <contact>
                <cont_name>aaa</cont_name>
                <cont_address>street 01</cont_address>
            </contact>
            <contact>
                <cont_name>bbb</cont_name>
                <cont_address>street 02</cont_address>
            </contact>
            <contact>
                <cont_name>ccc</cont_name>
                <cont_address>street 03</cont_address>
            </contact>
            <!-- more contacts -->
        </contacts>
        <records_of_type_c>
        </records_of_type_c>
    </complex_xml>

So I expect to get following flat file

    10-10-2011some info
    emp 0001   abc
    emp 0002   def
    emp 0003   xyz
    .
    .
    .
    cont aaa   street 01
    cont bbb   street 02
    cont ccc   street 03
    .
    .
    .


How can I define the BeanIO stream to read an xml that contains different information blocks?

Kevin

unread,
May 30, 2014, 9:34:31 PM5/30/14
to bea...@googlegroups.com
Please refer to the reference guide at http://beanio.org/2.1/docs/reference and try it out.  If you have more specific question, post them back here.

Thanks,
Kevin
Reply all
Reply to author
Forward
0 new messages