I am looking here for advice on how to handle my problem, and to know if there is already some tools working like this, that I am not aware of... Well, I have to communicate a lot of data from my system to another using their custom binary file format to exchange data. I have many of these (tlv like) binary files to generate and I am searching how to achieve my goal simply without handwriting to much code because I was told that the files format could evolve pretty soon.
For example here are 2 tables I have in my system (a list of products and their labels in different iso code) :
Table of products :
----------
SAL_PRODUCT
----------
ID          NUMBER(3)
VENDOR_ID       NUMBER (3)
MODEL_REF   VARCHAR2(30)
----------
Table of product labels :
----------
SAL_PRODUCT_LABEL 
---------- 
PRODUCT_ID      NUMBER(3) 
ISO_LANG_CODE   VARCHAR2(5) 
LABEL       VARCHAR2(40) 
---------- 
I have to produce a binary file similar as this structure :
- [Byte-size] <-- total size in byte of the message
- [Elm-count] <-- number of products - [Byte-size] <-- size in byte of first message (product n° 1) 
- [ID] <-- 1 byte product ID 
- [VENDORID] <-- 1 byte product vendor ID - [Elm-count] <-- number of product labels - [Byte-size] <-- size in byte of first message (label n° 1 of product n° 1) 
- [LANG_ID] <-- string ISO lang code on 5 caracters length 
- [LABELID] <-- String Label of product n° 1 for the current lang_id on 30 caracters length 
 
 
 
I figure out I must create a file generator able to work with an xml metadata file as this :
<messages type="product" select="select ID,VENDOR_ID, MODEL_REF from SAL_PRODUCT order by 1">
    <message>
        <prop type="ID"/>
        <prop type="VENDOR_ID" />
        <messages type="labels" select="select product_id, ISO_LANG_CODE as LANGID, LABEL from  SAL_PRODUCT_LABEL" joinclause="product.ID = labels.product_id " >
           <message  >  
            <prop type="LANGID" />
            <prop type="LABEL" />
           </message>
        </messages>
        <prop type="MODEL_REF"/>
    </message>  
</messages>     
But all my C# code sould be dynamic and able to parse and work with the nested structure.... From here I do not know how to handle my problem :
- does I have chose the right solution ? 
- how would you handle this kind of problem? 
Thank you for any help
 
     
    