Question on parsing file into collections RRS feed

  • Question

  • Hi, I have a file that has the following format:

    1) FileHeader

    2) Group Header

    3) Section Header
    4) 4 different records types identifying 1 item (not all record type may be present).  These 4 records are
    repeated numerous times - each set being a different item in that section.
    5) Section Footer

    6) Repeat Section Header to Section Footer....

    7) Group Footer

    8) Repeat another Group Header to Group Footer....

    9) File Footer

    I am trying to parse all that information into a meaninful collection and here's what I've come up with so far.

    I have a class for the File Header and File Footer that includes collection for Groups.
    I have a class for the Group Header and Footer that includes a collection for Sections.
    I have a class for the Section Header and Footer that includes a item collection - the item collection will be able to hold all the detail records pertinent to that single item.

    My thought process is:

    Create an instance of the File class and as I read the File Header and Footer, save the data as necessary.  Everytime I hit a Group record, create an instance of the Group class and fill in the data and then add it to the Group collection in the File class.  etc etc as I work my way down.

    My question is this:  am I being efficient or is there a better way to store the information?  I'm not done yet but I can imagine the drill down process to get to the lower items might be hectic so hopefull I can provide some meaninful methods to make it easier.

    Wednesday, March 25, 2009 8:16 PM


  • Is this information that you want persisted?

    How about created an XmlDocument or XElement

        <File ID="name1">

    John Grove - TFD Group, Senior Software Engineer, EI Division,
    • Proposed as answer by Harry Zhu Monday, March 30, 2009 8:14 AM
    • Marked as answer by Harry Zhu Tuesday, March 31, 2009 2:56 AM
    Wednesday, March 25, 2009 8:42 PM